home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / UTILITY / MOUSE_28 / SOURCE / MOUSE28.S
Encoding:
Text File  |  1990-03-08  |  70.9 KB  |  3,276 lines

  1. **************************************************************************
  2. *                                                                        *
  3. *  MOUSE-KA-MANIA!                                                       *
  4. *                                                                        *
  5. *  by Charles F. Johnson                                                 *
  6. *                                                                        *
  7. *  Copyright 1987 Charles F. Johnson & Little Green Footballs Software.  *
  8. *  All rights reserved.                                                  *
  9. *                                                                        *
  10. *  This source code is for the MADMAC assembler.                         *
  11. *                                                                        *
  12. **************************************************************************
  13.  
  14. * -----------------------------------
  15. *  Last revision: 08/27/87  13:14:48
  16. * -----------------------------------
  17.  
  18.     .include    "C:\\AS68\\OBJECT.S"
  19.  
  20. * Object index equates
  21.  
  22. savebt    =    22
  23. loadbt    =    29
  24. clrmbt    =    30
  25. clrdbt    =    23
  26. invdbt    =    24
  27. invmbt    =    31
  28. upbt    =    11
  29. leftbt    =    12
  30. downbt    =    18
  31. ritebt    =    13
  32. mirdbt    =    25
  33. mirmbt    =    32
  34. exitbt    =    26
  35. instbt    =    5
  36. remvbt    =    6
  37. undobt    =    27
  38. rotbt    =    28
  39. cdowbt    =    8
  40. cupbt    =    10
  41. colval    =    9
  42. colttl    =    7
  43. frmttl    =    14
  44. frdown    =    15
  45. frup    =    17
  46. frmval    =    16
  47. anonof    =    21
  48.  
  49. loinst    =    3
  50. loremv    =    7
  51. loexit    =    11
  52. locolr    =    10
  53. lodown    =    12
  54. locval    =    13
  55. loup    =    14
  56. losvbt    =    5
  57.  
  58. * Guaranteed memory locations
  59.  
  60. ipl_vec        =    $70    ; System vertical blank vector
  61. sshiftmod    =    $44C    ; System resolution variable
  62.  
  63. * These locations are undocumented, and are not guaranteed to remain the same
  64. * in future versions of TOS.  However, they are referenced by negative
  65. * offsets from the Line A variable areas, and they do work with the version
  66. * of TOS in the Mega ST.
  67.  
  68. ignore        =    -$153    ; Negative offset to mouse packet ignore flag
  69. but_stat    =    -$15C    ; Offset to mouse button status variable
  70. mouse_x        =    -$25A    ; Mouse X location (pokeable)
  71.  
  72.     .text
  73.  
  74.     move.l    #ustack,a7    ; Accessory initialization
  75.  
  76.     dc.w    $A000        ; Line A init
  77.     move.l    a0,line_a
  78.  
  79.     move.l    #ap1rsv,a5
  80.     clr.l    (a5)        ; appl_init
  81.     clr.l    4(a5)
  82.     clr.l    8(a5)
  83.     clr.l    12(a5)
  84.     move.l    #a_init,aespb
  85.     bsr    aes
  86.  
  87.     move.l    #m_reg,aespb    ; menu_register
  88.     move    intout,intin
  89.     move.l    #accmsg,addrin
  90.     bsr    aes
  91.     move    intout,menuid    ; Save menu ID number
  92.  
  93.     move.l    #g_hand,aespb    ; graph_handle
  94.     bsr    aes
  95.     move    intout,ghandl
  96.  
  97.     move.l    #e_timr,aespb    ; Call evnt_timer to let GEM finish doing
  98.     clr.l    intin        ; whatever the heck it does to initialize
  99.     bsr    aes        ; (Wait for _zero_ milliseconds)
  100.  
  101.     move.l    #g_mous,aespb    ; Set arrow cursor so we can search for it
  102.     clr.w    intin
  103.     bsr    aes
  104.  
  105.     move.l    #$2000,a5    ; Start searching for the mouse definition
  106. sm_1:    move.l    #arrow_data,a4    ; Pointer to my arrow data
  107.     move    #31,d5        ; 32 words to check
  108. sm_2:    move.w    (a5),d0        ; Get a word
  109.     cmp.w    (a4),d0        ; Match first word of arrow definition?
  110.     beq.s    sm_3        ; Yes, check the rest
  111.     addq    #2,a5        ; Increment pointer
  112.     bra    sm_2
  113. sm_3:    move.l    a5,a0        ; Save address of first match
  114. sm_4:    cmp.w    (a5)+,(a4)+    ; See if we have the whole mouse here
  115.     bne    sm_1
  116.     dbf    d5,sm_4
  117.     move.l    a0,sprtad    ; Found it! Save mouse sprite buffer address
  118.  
  119.     move.l    #r_obfx,aespb    ; Adjust coordinates in editor object tree
  120.     move.l    #editbx,addrin
  121.     move    #objnum,d5
  122. fxedt:    move    d5,intin
  123.     bsr    aes
  124.     dbf    d5,fxedt
  125.  
  126.     move.l    #lowbox,addrin    ; Now adjust the low res object tree
  127.     move    #lo_num,d5
  128. fxlow:    move    d5,intin
  129.     bsr    aes
  130.     dbf    d5,fxlow
  131.  
  132.     move    #4,-(sp)    ; Get resolution
  133.     trap    #14
  134.     addq    #2,sp
  135.  
  136.     cmp.w    #2,d0        ; Hi res?
  137.     bne.s    ckmed1        ; No, skip
  138.     move.l    #hi_val,valsav    ; Save address of color translation table
  139.     bra.s    savres        ; based on the current resolution
  140. ckmed1:    cmp.w    #1,d0
  141.     bne.s    cklow1
  142.     move.l    #med_val,valsav
  143.     bra.s    savres
  144. cklow1:    move.l    #low_val,valsav
  145. savres:    move    d0,o_res    ; Save boot resolution
  146.  
  147.     cmp.w    #2,d0        ; High res?
  148.     beq.s    hi1        ; Yes, skip
  149.     move.l    #y_off,a0    ; Adjust the Y coordinate variables
  150.     move    #4,d5        ; 5 of these
  151. adjres:    lsr.w    (a0)+        ; Divide by 2
  152.     dbf    d5,adjres
  153.     move.w    #160,y_scr
  154.  
  155. hi1:    subq.w    #4,upco        ; Adjust the positions of a few objects
  156.     subq.w    #4,leftco
  157.     subq.w    #4,riteco
  158.     subq.w    #4,downco
  159.     addq.w    #2,datco
  160.     addq.w    #2,mskco
  161.     cmp.w    #2,d0        ; d0 still holds resolution (right?)
  162.     bne.s    med1        ; Not hi res, skip
  163.     addq.w    #3,cop_co+2
  164.     subq.w    #3,footco+2    ; Shuffle them objects!
  165.     subq.w    #6,leftco+2
  166.     subq.w    #6,riteco+2
  167.     sub.w    #12,downco+2
  168.     bra.s    fsel_search
  169. med1:    subq.w    #3,leftco+2    ; Have to move 'em by different amounts
  170.     subq.w    #3,riteco+2    ; in medium res
  171.     subq.w    #6,downco+2
  172.     move    #4,filhot    ; Set medium res hot spot fill style
  173.     move    #4,fillst    ; Set mask fill style
  174.     move    #4,celsiz    ; Editing grid cell size
  175.     move    #2,planes    ; Number of color planes
  176.  
  177. fsel_search:
  178.     clr.w    fsflag        ; Clear "search failed" flag
  179.     move.l    #$A000,a5    ; Start searching at $A000
  180. s_1:    move.l    #itmtxt,a4    ; Get pointer to search string ("ITEM SELECTOR")
  181.     move    #12,d5        ; Get number of bytes to search for
  182. s_2:    move.b    (a5),d0        ; Get a character
  183.     cmp.b    (a4),d0        ; Is it "I"?
  184.     beq.s    s_3        ; Yes, check for rest of string
  185.     addq    #1,a5        ; Increment the pointer
  186.     cmp.l    #$40000,a5
  187.     bne    s_2
  188.     bra.s    s_6        ; Keep searching
  189. s_3:    move.l    a5,a0        ; Save address of first match
  190. s_4:    cmp.b    (a5)+,(a4)+    ; See if we have the whole string
  191.     bne    s_1        ; No, go search more
  192.     dbf    d5,s_4        ; Count down and loop
  193.     tst.b    13(a0)        ; There should be a zero after it
  194.     bne    s_1
  195.  
  196. s4_2:    move.l    a0,d0        ; Found it! Save address of text in d0
  197.     move.l    a0,iasav
  198.     move.l    a0,d1        ; Move address to d1 so we can manipulate it
  199.     bclr    #0,d1        ; Clear odd bit
  200.     move.l    d1,a0        ; Back to a0
  201. s_5:    subq    #2,a0        ; Decrement the pointer to memory
  202.     cmp.l    #$A000,a0    ; Back at the start already?
  203.     beq.s    s_6        ; Yes, skip ahead
  204.     move.l    (a0),d1        ; Get a longword
  205.     cmp.l    d1,d0        ; Is this the pointer to "ITEM SELECTOR"?
  206.     bne    s_5        ; No, search more
  207.     move.l    a0,itmadr    ; Save address of pointer
  208.     move    8(a0),ilensv    ; Save original string length
  209.     bra.s    search
  210.  
  211. s_6:    move    #1,fsflag    ; Set flag to indicate search failure
  212.  
  213. search:
  214.     clr.w    lowflg
  215.     cmp.w    #2,o_res    ; High res?
  216.     beq    getdrv        ; Yes, skip this
  217.     move.l    #$A000,a5
  218. sr_1:    move.l    #restxt,a4    ; Find object spec of "Low" button in the
  219.     move    #14,d5        ; "Set Preferences" desktop dialog box
  220. sr_2:    move.b    (a5),d0
  221.     cmp.b    (a4),d0
  222.     beq.s    sr_3
  223.     addq    #1,a5
  224.     cmp.l    #$40000,a5
  225.     beq.s    sr_6
  226.     bra    sr_2
  227. sr_3:    move.l    a5,a0
  228. sr_4:    cmp.b    (a5)+,(a4)+
  229.     bne    sr_1
  230.     dbf    d5,sr_4
  231.     tst.b    15(a0)        ; Once again, there has to be a zero after it
  232.     bne    sr_1
  233.  
  234.     move.l    a0,d0
  235.     move.l    a0,d1
  236.     bclr    #0,d1
  237.     move.l    d1,a0
  238. sr_5:    subq    #2,a0
  239.     cmp.l    #$A000,a0
  240.     beq.s    sr_6
  241.     move.l    (a0),d1
  242.     cmp.l    d1,d0
  243.     bne    sr_5
  244.     subq    #2,a0        ; Point to status word of "Low" button
  245.     move.l    a0,d0
  246.     sub.l    #96,d0        ; Get pointer to status word of "OK" button
  247.     move.l    d0,res_okptr
  248.     cmp.w    #2,o_res
  249.     beq.s    set_lo
  250.     tst.w    o_res
  251.     beq.s    set_me
  252. set_lo:    clr.l    d0
  253.     bra.s    mult24
  254. set_me:    move.l    #1,d0
  255. mult24:    mulu    #24,d0        ; Compute the index to the button that
  256.     add.l    d0,a0        ; should NOT be selected
  257.     move.l    a0,res_optr    ; Save pointer to its status word
  258.     bra.s    getdrv
  259.  
  260. sr_6:    move    #1,lowflg
  261.  
  262. getdrv:    move    #$19,-(sp)    ; Get current drive
  263.     trap    #1
  264.     addq    #2,sp
  265.     add.b    #65,d0        ; Convert to ASCII
  266.     move.l    #savdir,a4
  267.     move.l    #svadir,a2
  268.     move.l    #loddir,a5
  269.     move.l    #loadir,a3
  270.     move.b    d0,(a2)+
  271.     move.b    d0,(a3)+
  272.     move.b    d0,(a4)+
  273.     move.b    d0,(a5)+
  274.     move.l    #datext,a0
  275.     move.l    #aniext,a1
  276.     move    #7,d5
  277. cpydir:    move.b    (a0),(a4)+    ; Move in the rest of the directory lines
  278.     move.b    (a0)+,(a5)+
  279.     move.b    (a1),(a2)+
  280.     move.b    (a1)+,(a3)+
  281.     dbf    d5,cpydir
  282.  
  283.     clr.w    colflg        ; Clear color change flag
  284.     clr.w    insflg        ; Clear installed flag
  285.     clr.w    antflg        ; Clear animation title flag
  286.     clr.w    onoff        ; Clear animation on/off flag
  287.     clr.w    franum        ; Clear frame number
  288.     clr.w    moucnt
  289.     clr.w    vbi_on
  290.     clr.w    diflag
  291.     move.w    #1,nframs    ; Set number of frames in loop
  292.  
  293.     tst.w    o_res        ; Are we in low res?
  294.     bne.s    rdef1        ; No, skip
  295.     move.l    #lowdef,a5    ; Set address of default mouse filename
  296.     bra.s    rdef3        ; based on current res
  297. rdef1:    cmp.w    #1,o_res
  298.     bne.s    rdef2
  299.     move.l    #meddef,a5
  300.     bra.s    rdef3
  301. rdef2:    move.l    #hidef,a5
  302. rdef3:    move.l    a5,filadr
  303.     bsr    sav_exist
  304.     bmi    no_def
  305.     cmp.l    #74,dta+26    ; Is it a data file? (74 bytes)
  306.     beq    rdef4        ; Yes, skip
  307.     bsr    open_file    ; Open the file
  308.     bmi    no_def        ; Error, bail
  309.     move    d0,fhandl
  310.     move.l    #mouse_array,a5    ; Set address of mouse animation array
  311.     move.l    #74*32,d5    ; Length of data
  312.     bsr    read_file
  313.     bmi    no_def
  314.     move.l    #nframs,a5    ; Now read number of frames
  315.     move.l    #2,d5
  316.     bsr    read_file
  317.     move.l    #delval,a5    ; And delay value
  318.     bsr    read_file
  319.     bsr    clos_file
  320.     cmp.w    #32,nframs    ; # of frames greater than 32?
  321.     bhi.s    rdef3_0        ; Yes, exit
  322.     cmp.w    #99,delval
  323.     bhi.s    rdef3_0
  324.     move.l    #mouse_array,a0
  325.     move    #31,d0
  326. ckdanf:    cmp.w    #15,(a0)    ; Check all hotspot positions
  327.     bhi.s    rdef3_0        ; and color values
  328.     cmp.w    #15,2(a0)
  329.     bhi.s    rdef3_0
  330.     cmp.w    #15,6(a0)
  331.     bhi.s    rdef3_0
  332.     cmp.w    #15,8(a0)
  333.     bhi.s    rdef3_0
  334.     add.l    #74,a0
  335.     dbf    d0,ckdanf
  336.     bra.s    rdef3_1
  337.  
  338. rdef3_0:
  339.     bsr    clear_array
  340.     bra.s    no_def
  341.  
  342. rdef3_1:
  343.     bsr    arr_2_frm    ; Copy first frame to editing area
  344.     bsr    init_nfrm    ; Initialize frame number box
  345.     move.l    #anonms,tinf5    ; Set "Animation ON" message
  346.     move.w    delval,vbtimr    ; Set the vertical blank timer
  347.     clr.w    moucnt        ; Clear the frame counter
  348.     move    #1,onoff    ; Now set the animation flag
  349.     bra.s    rdef5
  350.  
  351. rdef4:    bsr    open_file    ; Try to open default mouse file
  352.     bmi.s    no_def        ; Error, assume file not found
  353.     move    d0,fhandl    ; Save handle
  354.     move.l    #mouse_form,a5    ; Read mouse data from file
  355.     move.l    #74,d5
  356.     bsr    read_file
  357.     bsr    clos_file    ; Close it
  358.  
  359. rdef5:    bsr    cpy_inst    ; Copy it to the "installed" area
  360.     bsr    frm_2_arr
  361.  
  362.     bsr    init_col    ; Initialize the color indicators
  363.     move    #1,insflg    ; Set installed flag
  364.  
  365. no_def:    bsr    copy_mouse    ; Initialize the undo buffer
  366.  
  367.     pea    save_vbv
  368.     move.w    #38,-(sp)
  369.     trap    #14
  370.     addq    #6,sp
  371.  
  372.     tst.w    insflg        ; Mouse installed?
  373.     beq.s    evntms        ; No, skip
  374.  
  375.     move    #1,vbi_on    ; Turn on the vertical blank interrupt
  376.  
  377. evntms:    move.l    #e_mesg,aespb    ; Wait for GEM to send us a message
  378.     move.l    #mspipe,addrin
  379.     bsr    aes
  380.  
  381.     cmp.w    #40,mspipe    ; Is this an AC_OPEN message?
  382.     bne    evntms        ; No, go back
  383.     move    mspipe+8,d0    ; Is it for this accessory?
  384.     cmp.w    menuid,d0
  385.     bne    evntms        ; No, go back
  386.  
  387.     move.l    #w_updt,aespb    ; Call wind_update to block user actions
  388.     move    #1,intin
  389.     bsr    aes
  390.  
  391.     move    #2,-(sp)    ; Get address of screen RAM
  392.     trap    #14
  393.     addq    #2,sp
  394.     move.l    d0,screen    ; Save it
  395.  
  396.     move    #$19,-(sp)    ; Get current drive
  397.     trap    #1
  398.     addq    #2,sp
  399.     move    d0,curdrv    ; Save it
  400.  
  401.     clr.w    -(sp)        ; Get current pathname
  402.     move.l    #curpth,-(sp)
  403.     move    #$47,-(sp)
  404.     trap    #1
  405.     addq    #8,sp
  406.  
  407.     move    #4,-(sp)    ; Get current resolution
  408.     trap    #14
  409.     addq    #2,sp
  410.     move.w    d0,res
  411.  
  412.     tst.w    d0        ; Low res?
  413.     bne    continue    ; No, forge ahead
  414.  
  415.     bsr    open_window
  416.  
  417.     tst    d0
  418.     bmi    alrtx1
  419.  
  420.     tst    onoff        ; Animation on?
  421.     bne.s    arroff        ; Yes, turn off color change box
  422.     tst.w    insflg        ; Is a mouse installed?
  423.     bne.s    arr_on        ; Yes, skip ahead
  424.  
  425. arroff:    move    #DISABLED,locstt ; Disable the color change box
  426.     move    #DISABLED,lodstt
  427.     move    #DISABLED,loustt
  428.     move    #DISABLED,losstt
  429.     move.l    #blnkms,lovadr
  430.     bra.s    dolbox        ; And continue
  431. arr_on:    move    #NORMAL,locstt    ; Enable the color change box
  432.     move    #NORMAL,lodstt
  433.     move    #NORMAL,loustt
  434.     move    #NORMAL,losstt
  435.     tst    colflg
  436.     bne.s    ao_1
  437.     move.l    #dvalms,lovadr
  438.     bra.s    dolbox
  439. ao_1:    move.l    #mvalms,lovadr
  440.  
  441. dolbox:    move.l    #lowbox,addrin    ; Draw the low res dialog box
  442.     bsr    drawbx
  443.     move    #1,diflag
  444. loinpt:    bsr    formdo        ; Get user input
  445.  
  446.     bclr    #7,intout    ; Clear high bit in case of double-click
  447.     cmp.w    #loinst,intout    ; 'Install' button selected?
  448.     bne    alrt0        ; No, skip
  449.  
  450.     move    #NORMAL,loistt    ; De-select it
  451.  
  452.     clr.w    adflag
  453.     move.l    #dat_or_ani,a5    ; Show alert box
  454.     clr    d5
  455.     bsr    alert
  456.     cmp.w    #1,intout    ; Animation file?
  457.     bne.s    l_lo1
  458.     move    #1,adflag
  459.     bsr    fsl_aload
  460.     bra.s    l_lo2
  461. l_lo1:    bsr    fsl_dload    ; Set up fsel strings
  462. l_lo2:    bsr    fsel        ; Go call the dreaded File Selector
  463.  
  464.     move.l    filadr,a0
  465.     tst.b    (a0)        ; Got a filename?
  466.     beq    dolbox        ; No, exit
  467.     cmp.w    #1,intout+2    ; OK button?
  468.     bne    dolbox        ; No, exit
  469.  
  470.     bsr    set_path    ; Set drive and path
  471.  
  472.     move.l    filadr,a5    ; Load the mouse cursor file
  473.     bsr    open_file
  474.     bmi    alrtx        ; Error, bail out-ski
  475.     move    d0,fhandl    ; Save file handle
  476.  
  477.     tst    adflag
  478.     beq.s    l_lo3
  479.     bsr    chk_anfile
  480.     tst.w    a_good
  481.     beq.s    lo_a0
  482.     move.l    #notani,a5
  483.     move    #1,d5
  484.     bsr    alert
  485.     bsr    clos_file
  486.     bra    alrtx
  487. lo_a0:    moveq    #0,d0
  488.     bsr    lseek    
  489.     move.l    #mouse_array,a5
  490.     move.l    #74*32,d5
  491.     bsr    read_file
  492.     move.l    #nframs,a5
  493.     move.l    #2,d5
  494.     bsr    read_file
  495.     move.l    #delval,a5
  496.     bsr    read_file
  497.     bsr    clos_file
  498.     move.w    #1,insflg
  499.     move.w    #1,onoff
  500.     move    #1,vbi_on    ; Turn on the vertical blank interrupt
  501.     bra    arroff
  502.     
  503. l_lo3:    move.l    #mouse_form,a5    ; Read in the mouse
  504.     move.l    #74,d5
  505.     bsr    read_file
  506.     bmi    alrtx
  507.     bsr    clos_file    ; Close the file
  508.  
  509.     bsr    cpy_inst    ; Move it to 'installed' area
  510.     bsr    chg_mouse    ; Go change the mouse
  511.  
  512.     bsr    init_col    ; Initialize the color counters
  513.     move    #1,insflg    ; Set installed flag
  514.     clr.w    onoff
  515.  
  516.     move    #1,vbi_on    ; Turn on the vertical blank interrupt
  517.     bra    arr_on
  518.  
  519. alrt0:    cmp.w    #losvbt,intout    ; Save?
  520.     bne    alrt1
  521.  
  522.     move    #NORMAL,losstt    ; De-select the button
  523.  
  524.     tst    onoff        ; Animation on?
  525.     beq.s    al0_0
  526.     move    #losvbt,intin
  527.     move.l    #lowbox,addrin
  528.     bsr    objoff
  529.     bra    loinpt
  530.  
  531. al0_0:    bsr    fsl_dsave    ; Set up fsel text strings
  532.     bsr    fsel
  533.  
  534.     tst.b    savfil        ; Filename present?
  535.     beq    dolbox        ; Nope, exit
  536.     cmp.w    #1,intout+2    ; OK button?
  537.     bne    dolbox        ; No, must be 'Cancel'
  538.  
  539.     bsr    set_path    ; Set the pathname from fsel's output
  540.     move.l    #datext+3,a1
  541.     bsr    chk_extension    ; Add the .DAT extension (if none exists)
  542.  
  543.     bsr    sav_exist    ; See if the file already exists
  544.     bne.s    locrea        ; It doesn't, skip ahead
  545.     bsr    set_exist    ; Move the filename to the alert box
  546. lo_sho:    move.l    #exist,a5    ; Show alert box
  547.     move    #1,d5
  548.     bsr    alert
  549.     cmp.w    #1,intout    ; Overwrite the file?
  550.     bne    dolbox        ; No, split
  551.     move.l    #savfil,a0
  552.     bsr    delete_file
  553.  
  554. locrea:    clr.w    -(sp)        ; Create the data file
  555.     pea    savfil
  556.     move    #$3C,-(sp)
  557.     trap    #1
  558.     addq    #8,sp
  559.     tst.w    d0
  560.     bmi    dolbox
  561.     move    d0,fhandl
  562.  
  563.     move.l    #m_form2,-(sp)    ; Write the mouse buffer to the file
  564.     move.l    #74,-(sp)
  565.     move    fhandl,-(sp)
  566.     move    #$40,-(sp)
  567.     trap    #1
  568.     add    #12,sp
  569.  
  570.     cmp.l    #74,d0
  571.     beq.s    locr_1
  572.     move.l    #dskful,a5
  573.     move    #1,d5
  574.     bsr    alert
  575.     move.l    #savfil,a0
  576.     bsr    delete_file
  577.  
  578. locr_1:    bsr    clos_file    ; Close it
  579.     bra    dolbox
  580.  
  581. alrt1:    cmp.w    #loremv,intout    ; Remove?
  582.     bne.s    alrt2        ; No, skip
  583.     clr    vbi_on        ; Remove the vertical blank interrupt
  584.     move.l    #g_mous,aespb    ; And turn on the arrow
  585.     clr.w    intin
  586.     bsr    aes
  587.     clr.w    insflg
  588.     clr.w    onoff
  589.     move    #NORMAL,lorstt    ; De-select the button
  590.     bra    alrtx
  591.  
  592. alrt2:    cmp.w    #lodown,intout    ; Color down button?
  593.     bne.s    alrt3        ; No, hop over this code
  594.     tst    insflg        ; Installed?
  595.     beq    loinpt        ; No, go back
  596.     tst    onoff
  597.     bne    loinpt
  598.     tst.w    colflg        ; Which color are we changing?
  599.     bne.s    lcd_1        ; Must be the mask
  600.     tst.w    m_form2+8    ; Is this color zero already?
  601.     beq    loinpt        ; Yes, exit
  602.     subq.w    #1,m_form2+8    ; Decrement the color register value
  603.     move.l    #dvalms,a5    ; Address of data color text
  604.     bra.s    lcd_2        ; Skip over
  605. lcd_1:    tst.w    m_form2+6    ; Is it zero?
  606.     beq    loinpt        ; Yes, let's just forget about this
  607.     subq.w    #1,m_form2+6    ; Decrement it
  608.     move.l    #mvalms,a5    ; Address of mask color text
  609. lcd_2:    move.l    #1,d5        ; Two characters
  610.     add.l    d5,a5        ; Set pointer to 2nd character
  611. ldloop:    cmp.b    #'0',(a5)    ; Is it ASCII zero?
  612.     bne.s    ldl2        ; No, skip ahead
  613.     move.b    #'9',(a5)    ; Wrap it around to 9
  614.     bra.s    ldl3
  615. ldl2:    subq.b    #1,(a5)        ; Decrement the letter
  616.     bra.s    lodrw1
  617. ldl3:    subq    #1,a5        ; Set pointer to next place
  618.     dbf    d5,ldloop    ; Do the 2nd letter
  619.     bra.s    lodrw1        ; Go draw the text object
  620.  
  621. alrt3:    cmp.w    #loup,intout    ; Color up button?
  622.     bne    alrt4        ; No, get out!
  623.     tst    insflg        ; Installed?
  624.     beq    loinpt
  625.     tst    onoff
  626.     bne    loinpt
  627.     tst.w    colflg        ; The rest of this code is identical to
  628.     bne.s    lcu_1        ; the above section, except that it handles
  629.     cmp.w    #15,m_form2+8    ; incrementing the color value
  630.     beq    loinpt
  631.     addq.w    #1,m_form2+8
  632.     move.l    #dvalms,a5
  633.     bra.s    lcu_2
  634. lcu_1:    cmp.w    #15,m_form2+6
  635.     beq    loinpt
  636.     addq.w    #1,m_form2+6
  637.     move.l    #mvalms,a5
  638. lcu_2:    move.l    #1,d5
  639.     add.l    d5,a5
  640. luloop:    cmp.b    #'9',(a5)
  641.     bne.s    lul2
  642.     move.b    #'0',(a5)
  643.     bra.s    lul3
  644. lul2:    addq.b    #1,(a5)
  645.     bra.s    lodrw1
  646. lul3:    subq    #1,a5
  647.     dbf    d5,luloop
  648. lodrw1:    bsr    chg_mouse    ; Go change the mouse's color
  649. lodraw:    move    #locval,intin    ; Index of object to draw
  650.     move.l    #lowbox,addrin    ; Address of object tree
  651.     bsr    objoff        ; Go draw it
  652.     bra    loinpt
  653.  
  654. alrt4:    cmp.w    #locolr,intout    ; Data/Mask toggle?
  655.     bne.s    alrtx        ; No, skip
  656.     tst    insflg
  657.     beq    loinpt
  658.     tst    onoff
  659.     bne    loinpt
  660.     eor.w    #1,colflg    ; Toggle the flag
  661.     tst.w    colflg        ; Which one is it?
  662.     beq.s    lsw_1        ; It's data, skip ahead
  663.     move.l    #mcolms,tinf10    ; Set pointers to text in object tree
  664.     move.l    #mvalms,lovadr
  665.     bra.s    lsw_2
  666. lsw_1:    move.l    #dcolms,tinf10
  667.     move.l    #dvalms,lovadr
  668. lsw_2:    move    #locolr,intin
  669.     move.l    #lowbox,addrin
  670.     bsr    objoff        ; Go draw the object
  671.     bra    lodraw
  672.  
  673. alrtx:    bsr    res_dpath    ; Reset the drive and pathnames
  674.  
  675.     move    #NORMAL,loestt
  676.  
  677.     move    #3,intin
  678.     bsr    dial
  679.  
  680.     move.l    #w_clos,aespb    ; Close window so the application gets a
  681.     move    whandl,intin    ; redraw message
  682.     bsr    aes
  683.     move.l    #w_del,aespb    ; Now delete the window
  684.     bsr    aes
  685.  
  686. alrtx1:    move.l    #w_updt,aespb    ; Allow user actions again
  687.     clr.w    intin        ; (Hah! Were they ever disabled???)
  688.     bsr    aes
  689.  
  690.     clr.w    diflag
  691.  
  692.     bra    evntms        ; Wait patiently for another message
  693.  
  694. * Subroutines for low-res dialog box (strange place for them, I know)
  695.  
  696. chg_mouse:
  697.     move.l    #g_mous,aespb    ; Change that mousey!
  698.     move    #255,intin
  699.     move.l    #m_form2,addrin
  700.     bra    aes
  701.  
  702. fsl_dload:
  703.     move.l    #i_load,txtadr    ; Set up the 'Load' fsel text strings
  704.     move    #il_len,itmlen
  705.     move.l    #loddir,diradr
  706.     move.l    #lodfil,filadr
  707.     rts
  708.  
  709. fsl_aload:
  710.     move.l    #i_aloa,txtadr
  711.     move    #iallen,itmlen
  712.     move.l    #loadir,diradr
  713.     move.l    #loafil,filadr
  714.     rts
  715.  
  716. fsl_dsave:
  717.     move.l    #i_save,txtadr    ; The 'Save' fsel text strings
  718.     move    #is_len,itmlen
  719.     move.l    #savdir,diradr
  720.     move.l    #savfil,filadr
  721.     rts
  722.  
  723. fsl_asave:
  724.     move.l    #i_asav,txtadr
  725.     move    #iaslen,itmlen
  726.     move.l    #svadir,diradr
  727.     move.l    #svafil,filadr
  728.     rts
  729.  
  730. sav_exist:
  731.     pea    dta        ; Set DTA address
  732.     move    #$1A,-(sp)
  733.     trap    #1
  734.     addq    #6,sp
  735.     clr.w    -(sp)
  736.     move.l    filadr,-(sp)
  737.     move    #$4E,-(sp)    ; Check to see if the file already exists
  738.     trap    #1
  739.     addq    #8,sp
  740.     tst    d0        ; Does it?
  741.     rts
  742.  
  743. cpy_inst:
  744.     move.l    #mouse_form,a0    ; Copy mouse data to "installed" area
  745.     move.l    #m_form2,a1
  746.     move    #36,d5
  747. cpyi1:    move    (a0)+,(a1)+
  748.     dbf    d5,cpyi1
  749.     rts
  750.  
  751. set_exist:
  752.     move.l    #exname,a4    ; Clear filename space in alert box
  753.     move    #11,d5
  754. sete1:    move.b    #' ',(a4)+
  755.     dbf    d5,sete1
  756.     move.l    filadr,a5    ; Move filename into alert box
  757.     move.l    #exname,a4
  758.     move    #12,d5
  759. sete2:    tst.b    (a5)
  760.     beq.s    sete3
  761.     move.b    (a5)+,(a4)+
  762.     dbf    d5,sete2
  763. sete3:    rts
  764.  
  765.  
  766. * Here's where the editor code begins
  767.  
  768. continue:
  769.     move.l    #contrl,a5
  770.     move    #100,(a5)    ; v_opnvwk (Open Virtual Workstation)
  771.     clr.w    2(a5)
  772.     move    #11,6(a5)
  773.     move    ghandl,12(a5)    ; Pass handle returned from graph_handle
  774.     move.l    #intin,a4
  775.     move.l    #9,d5
  776. vwrklp:    move    #1,(a4)+
  777.     dbf    d5,vwrklp
  778.     move    #2,(a4)
  779.     bsr    vdi1
  780.  
  781.     move    12(a5),vhandl    ; Save VDI handle
  782.  
  783.     move    #35,(a5)    ; Inquire current polyline attributes
  784.     clr.w    2(a5)        ; vql_attributes
  785.     clr.w    6(a5)
  786.     bsr    vdi
  787.  
  788.     move.l    #intout,a0
  789.     move    (a0)+,l_type    ; Save 'em
  790.     move    (a0)+,l_colr
  791.     move    (a0)+,d_mode
  792.     move    (a0)+,l_strt
  793.     move    (a0)+,l_end
  794.     move    ptsout,l_wid
  795.  
  796.     move    #37,(a5)    ; Inquire current fill attributes
  797.     clr.w    2(a5)        ; vqf_attributes
  798.     clr.w    6(a5)
  799.     bsr    vdi
  800.  
  801.     move.l    #intout,a0
  802.     move    (a0)+,f_type    ; Save these attributes too
  803.     move    (a0)+,f_colr
  804.     move    (a0)+,f_patt
  805.  
  806.     bsr    exch_button    ; Set the button routine to an rts
  807.  
  808. *    move.l    #intout,a5
  809. *    move.l    2(a5),wx    ; Dialog box centered coordinates
  810. *    move.l    6(a5),ww
  811. *    subq.w    #2,wx        ; Compensate for the shadow
  812. *    subq.w    #2,wy
  813. *    addq.w    #4,ww
  814. *    addq.w    #4,wh
  815.  
  816.     bsr    open_window
  817.  
  818.     tst    d0
  819.     beq.s    box    
  820.     move.l    #w_updt,aespb
  821.     clr.w    intin
  822.     bsr    aes
  823.     bra    ex2
  824.  
  825. box:    move.l    #editbx,addrin
  826.     bsr    drawbx        ; Draw the dialog box
  827.     move    #1,diflag
  828.  
  829.     dc.w    $A00A        ; Hide mouse
  830.  
  831.     move    #1,intin    ; Replace
  832.     bsr    write_mode
  833.  
  834.     move    #1,intin    ; Black lines
  835.     bsr    poly_color
  836.  
  837.     move    #1,intin    ; Ordinary straight lines
  838.     bsr    poly_type
  839.  
  840.     move    #1,ptsin    ; One pixel wide
  841.     clr.w    ptsin+2
  842.     bsr    poly_width
  843.  
  844.     clr.l    intin        ; Normal, squared ends
  845.     bsr    poly_ends
  846.  
  847.     move    #2,intin    ; Set fill style to dots
  848.     bsr    vsf_interior
  849.  
  850.     move    #16,d4        ; Loop counter
  851.     move.l    #ptsin,a4    ; Keep address of ptsin array in a4
  852.     move    #2,pt_num    ; Just two points
  853.  
  854. grid1:    move    #50,(a4)    ; Draw the editing grids
  855.     move    d4,d0
  856.     mulu    y_div,d0
  857.     add.w    y_off,d0
  858.     move    d0,2(a4)
  859.     move    #210,4(a4)
  860.     move    d4,d0
  861.     mulu    y_div,d0
  862.     add.w    y_off,d0
  863.     move    d0,6(a4)
  864.     bsr    polyline
  865.  
  866.     move    #250,(a4)
  867.     move    d4,d0
  868.     mulu    y_div,d0
  869.     add.w    y_off,d0
  870.     move    d0,2(a4)
  871.     move    #410,4(a4)
  872.     move    d4,d0
  873.     mulu    y_div,d0
  874.     add.w    y_off,d0
  875.     move    d0,6(a4)
  876.     bsr    polyline
  877.  
  878.     move    d4,d0
  879.     mulu    #10,d0
  880.     add.w    #50,d0
  881.     move    d0,(a4)
  882.     move    y_off,2(a4)
  883.     move    d4,d0
  884.     mulu    #10,d0
  885.     add.w    #50,d0
  886.     move    d0,4(a4)
  887.     move    y_bot,6(a4)
  888.     bsr    polyline
  889.  
  890.     move    d4,d0
  891.     mulu    #10,d0
  892.     add.w    #250,d0
  893.     move    d0,(a4)
  894.     move    y_off,2(a4)
  895.     move    d4,d0
  896.     mulu    #10,d0
  897.     add.w    #250,d0
  898.     move    d0,4(a4)
  899.     move    y_bot,6(a4)
  900.     bsr    polyline
  901.  
  902.     dbf    d4,grid1
  903.  
  904.     move    #434,(a4)    ; Draw the mouse-change rectangle
  905.     move    y_off,2(a4)
  906.     move    #516,4(a4)
  907.     move    y_off,6(a4)
  908.     move    #516,8(a4)
  909.     move    chang1,10(a4)
  910.     move    #434,12(a4)
  911.     move    chang1,14(a4)
  912.     move    #434,16(a4)
  913.     move    y_off,18(a4)
  914.     move    #5,pt_num
  915.     bsr    polyline
  916.  
  917.     move    #1,intin
  918.     bsr    vsf_color
  919.     move    #8,intin
  920.     bsr    vsf_style
  921.  
  922.     move.l    #contrl,a5
  923.     move    #114,(a5)
  924.     move    #2,2(a5)
  925.     clr.w    6(a5)
  926.     move    #434,ptsin    ; Fill the top half of the mouse-change
  927.     move    y_off,ptsin+2    ; rectangle
  928.     move    #516,ptsin+4
  929.     move    chang2,ptsin+6
  930.     bsr    vdi
  931.  
  932.     bsr    show_mouse    ; Oh, there's that little mousey!
  933.  
  934.     clr.w    m_flag        ; Clear mouse-change flag
  935.     bsr    map_grid    ; Go map the shape
  936.     clr.w    d_flag        ; Clear the drawing flag
  937.  
  938. the_big_loop:
  939.     bsr    sample_mouse    ; Let's see what's happening
  940.  
  941.     move.b    intout+1,butsav    ; Save button status
  942.     move.l    ptsout,mousex    ; and X and Y coordinates
  943.  
  944.     move.l    #o_cfnd,aespb    ; objc_find --- get the index number of the
  945.     move.l    #intin,a0    ; object under the mouse cursor
  946.     move.l    #$00000005,(a0)+
  947.     move.l    mousex,(a0)+
  948.     move.l    #editbx,addrin
  949.     bsr    aes
  950.  
  951.     move    intout,d5
  952.     move.l    #ob_inx,a0
  953.     sub.w    d0,d0
  954. ck_obs:    cmp.w    (a0)+,d5    ; Compare it with the active object list
  955.     beq.s    gotobj        ; Got one!
  956.     addq.w    #1,d0        ; Increment counter
  957.     cmp.w    #oi_len,d0    ; Done?
  958.     bne    ck_obs        ; No, do the rest
  959.     bra    ckchng        ; If we get here, we're not over an active object
  960.  
  961. gotobj:    move    d0,numrtn    ; Save index into routines
  962.     move    d5,o_indx    ; Save object index
  963.     move.l    #o_coff,aespb    ; Get coordinates of object we're over
  964.     move    d5,intin
  965.     move.l    #editbx,addrin
  966.     bsr    aes
  967.     move.l    intout+2,x_obj1    ; Save X and Y coordinates
  968.     move    intout+2,d0
  969.     move    intout+4,d1
  970.     moveq    #0,d4
  971.     move    o_indx,d4
  972.     mulu    #24,d4
  973.     add.l    #editbx,d4
  974.     move.l    d4,a0        ; a0 -> address of object in tree
  975.  
  976.     move.l    d4,o_asav
  977.     add.w    20(a0),d0    ; Compute diagonal opposite point of the box
  978.     add.w    22(a0),d1    ; by adding the width and height to the
  979.     move    d0,x_obj2    ; X and Y
  980.     move    d1,y_obj2
  981.     move.l    20(a0),w_obj    ; Save width and height
  982.  
  983.     move    #0,butflg    ; Clear button flag
  984.  
  985. ob_loop:
  986.     bsr    sample_mouse    ; Where am I? (said the amnesia victim)
  987.     move    ptsout,d0    ; Get current X coordinate
  988.     cmp.w    x_obj1,d0    ; Check to see if we're still over the
  989.     blt    ortn_exit    ; same object; if not, exit
  990.     cmp.w    x_obj2,d0
  991.     bgt    ortn_exit
  992.     move    ptsout+2,d0
  993.     cmp.w    y_obj1,d0
  994.     blt    ortn_exit
  995.     cmp.w    y_obj2,d0
  996.     bgt    ortn_exit
  997.  
  998.     btst    #0,intout+1    ; Pressing the left button?
  999.     bne.s    ol1_2        ; Yes, go ahead
  1000.     btst    #1,intout+1    ; Right button?
  1001.     beq    ob_loop        ; No, go back
  1002.  
  1003. ol1_2:    move    #1,butflg    ; Yes, set the button flag
  1004.  
  1005.     move.w    o_indx,d0
  1006.     cmp.w    #cdowbt,d0
  1007.     beq.s    oloop2
  1008.     cmp.w    #cupbt,d0
  1009.     beq.s    oloop2
  1010.     cmp.w    #colttl,d0
  1011.     beq.s    oloop2
  1012.     cmp.w    #frmttl,d0
  1013.     beq.s    oloop2
  1014.     cmp.w    #frdown,d0
  1015.     beq.s    oloop2
  1016.     cmp.w    #frup,d0
  1017.     beq.s    oloop2
  1018.     cmp.w    #anonof,d0
  1019.     beq.s    oloop2
  1020.     move.l    o_asav,a0    ; Address of object in tree
  1021.     or.w    #SELECTED,10(a0) ; Turn it on, dead man
  1022.     bsr    obdraw        ; And draw it
  1023.  
  1024. oloop2:    bsr    sample_mouse    ; Where am I now?
  1025.  
  1026.     move.w    o_indx,d0
  1027.     cmp.w    #frdown,d0
  1028.     beq.s    ol2_2
  1029.     cmp.w    #frup,d0
  1030.     beq.s    ol2_2
  1031.  
  1032.     btst    #0,intout+1    ; Still pressing the button?
  1033.     bne    oloop2        ; Yes, loop
  1034.     btst    #1,intout+1
  1035.     bne    oloop2
  1036. ol2_2:    move    ptsout,d0    ; OK, we let go of the button. Now let's
  1037.     cmp.w    x_obj1,d0    ; check to see whether we're still over
  1038.     blt.s    go_oex        ; the same object; if not, exit
  1039.     cmp.w    x_obj2,d0
  1040.     bgt.s    go_oex
  1041.     move    ptsout+2,d0
  1042.     cmp.w    y_obj1,d0
  1043.     blt.s    go_oex
  1044.     cmp.w    y_obj2,d0
  1045.     ble.s    oloop3
  1046. go_oex:    move    #-1,numrtn
  1047.     bra    ortn_exit
  1048.  
  1049. oloop3:    moveq    #0,d0
  1050.     move    numrtn,d0    ; Get index into address table
  1051.     lsl.w    #2,d0        ; Multiply by 4 (to adjust for longwords)
  1052.     add.l    #rtn_table,d0    ; Add start of table
  1053.     move.l    d0,a5        ; Move it to a place where it can do some good
  1054.     move.l    (a5),a5        ; Get routine address into a5
  1055.     jmp    (a5)        ; And jump to it!
  1056.  
  1057. * Object-related routines
  1058.  
  1059. save:
  1060.     clr.w    adflag
  1061.     bsr    repl_button
  1062.     move.l    #dat_or_ani,a5    ; Show alert box
  1063.     clr    d5
  1064.     bsr    alert
  1065.     bsr    exch_button
  1066.     cmp.w    #1,intout    ; Animation file?
  1067.     bne.s    sv1
  1068.     move    #1,adflag    ; Set flag
  1069.     bsr    fsl_asave
  1070.     bra.s    sv2
  1071.  
  1072. sv1:    bsr    fsl_dsave    ; Set fsel parameters
  1073. sv2:    bsr    repl_button    ; Restore the button vector
  1074.     bsr    fsel        ; Call the dreaded File Selector
  1075.     bsr    exch_button    ; Point button vector to an RTS again
  1076.  
  1077.     move.l    filadr,a0
  1078.     tst.b    (a0)        ; Got a filename?
  1079.     beq    ortn_exit
  1080.     cmp.w    #1,intout+2    ; OK button?
  1081.     bne    ortn_exit
  1082.  
  1083.     bsr    set_path    ; Set pathname
  1084.     tst    adflag
  1085.     beq.s    sv3
  1086.     move.l    #aniext+3,a1
  1087.     bra.s    sv4
  1088. sv3:    move.l    #datext+3,a1
  1089. sv4:    bsr    chk_extension    ; Check for extension
  1090.  
  1091.     bsr    sav_exist    ; Does the file already exist?
  1092.     bne.s    create        ; No, continue
  1093.  
  1094.     bsr    set_exist    ; Copy the name into the alert box
  1095.  
  1096. sho_al:    bsr    repl_button    ; Replace the system button routine vector
  1097.  
  1098.     move.l    #exist,a5    ; Show alert box
  1099.     move    #1,d5
  1100.     bsr    alert
  1101.  
  1102.     bsr    exch_button    ; Turn off the button routine again
  1103.  
  1104.     cmp.w    #1,intout    ; Yes button?
  1105.     bne    sav_x        ; No, exit
  1106.  
  1107.     move.l    filadr,a0
  1108.     bsr    delete_file
  1109.  
  1110. create:    clr.w    -(sp)        ; Create the data file
  1111.     move.l    filadr,-(sp)
  1112.     move    #$3C,-(sp)
  1113.     trap    #1
  1114.     addq    #8,sp
  1115.     tst.w    d0
  1116.     bmi    sav_x
  1117.     move    d0,fhandl
  1118.  
  1119.     tst    adflag
  1120.     beq.s    sv5
  1121.     move.l    #mouse_array,-(sp)
  1122.     move.l    #74*32,d5
  1123.     bra.s    sv6
  1124. sv5:    move.l    #mouse_form,-(sp) ; Write the mouse data to the file
  1125.     move.l    #74,d5
  1126. sv6:    move.l    d5,-(sp)
  1127.     move    fhandl,-(sp)
  1128.     move    #$40,-(sp)
  1129.     trap    #1
  1130.     add    #12,sp
  1131.  
  1132.     cmp.l    d5,d0
  1133.     beq.s    sv7
  1134. full:    bsr    repl_button
  1135.     move.l    #dskful,a5
  1136.     move    #1,d5
  1137.     bsr    alert
  1138.     bsr    exch_button
  1139.     move.l    filadr,a0
  1140.     bsr    delete_file
  1141.     bra.s    sv8
  1142.  
  1143. sv7:    tst    adflag        ; Data or animation?
  1144.     beq.s    sv8        ; Data, skip
  1145.     move.l    #nframs,-(sp)    ; Save number of frames and delay value
  1146.     move.l    #2,-(sp)
  1147.     move    fhandl,-(sp)
  1148.     move    #$40,-(sp)
  1149.     trap    #1
  1150.     add    #12,sp
  1151.     cmp.l    #2,d0
  1152.     bne    full
  1153.  
  1154.     move.l    #delval,-(sp)
  1155.     move.l    #2,-(sp)
  1156.     move    fhandl,-(sp)
  1157.     move    #$40,-(sp)
  1158.     trap    #1
  1159.     add    #12,sp
  1160.     cmp.l    #2,d0
  1161.     bne    full
  1162.  
  1163. sv8:    bsr    clos_file    ; Close it nice and tight
  1164. sav_x:    bra    ortn_exit
  1165.  
  1166. load:
  1167.     clr.w    adflag
  1168.     bsr    repl_button
  1169.     move.l    #dat_or_ani,a5    ; Show alert box
  1170.     clr    d5
  1171.     bsr    alert
  1172.     bsr    exch_button
  1173.     cmp.w    #1,intout    ; Animation file?
  1174.     bne.s    lo1
  1175.     move    #1,adflag
  1176.     bsr    fsl_aload
  1177.     bra.s    lo2
  1178.  
  1179. lo1:    bsr    fsl_dload    ; Same old fsel stuff as everywhere else
  1180. lo2:    bsr    repl_button
  1181.     bsr    fsel
  1182.     bsr    exch_button
  1183.  
  1184.     move.l    filadr,a0
  1185.     tst.b    (a0)        ; Filename?
  1186.     beq    ortn_exit
  1187.     cmp.w    #1,intout+2    ; OK button?
  1188.     bne    ortn_exit
  1189.  
  1190.     bsr    set_path
  1191.  
  1192.     move.l    filadr,a5
  1193.     bsr    open_file
  1194.     bmi    lod_x2
  1195.     move    d0,fhandl
  1196.  
  1197.     tst    adflag
  1198.     beq.s    lo3
  1199.  
  1200.     bsr    chk_anfile
  1201.     tst.w    a_good
  1202.     beq.s    lo2_2
  1203.  
  1204. lo2_1:    bsr    repl_button
  1205.     move.l    #notani,a5
  1206.     move    #1,d5
  1207.     bsr    alert
  1208.     bsr    exch_button
  1209.     bra.s    lod_x
  1210.  
  1211. lo2_2:    moveq    #0,d0
  1212.     bsr.s    lseek    
  1213.     move.l    #mouse_array,a5
  1214.     move.l    #74*32,d5
  1215.     bsr    read_file
  1216.     bmi.s    lod_x
  1217.     move.l    #nframs,a5
  1218.     move.l    #2,d5
  1219.     bsr    read_file
  1220.     move.l    #delval,a5
  1221.     bsr    read_file
  1222.     bsr    clos_file
  1223.     clr.w    franum
  1224.     move.b    #'0',frvlms
  1225.     move.b    #'1',frvlms+1
  1226.     bsr    arr_2_frm
  1227.     bsr    init_nfrm
  1228.     bra.s    lo4
  1229.  
  1230. lo3:    move.l    #mouse_form,a5    ; Read in the mouse data
  1231.     move.l    #74,d5
  1232.     bsr    read_file
  1233.     bmi.s    lod_x
  1234.  
  1235. lo4:    bsr    copy_mouse    ; Copy to undo buffer
  1236.     bsr    init_col    ; Initialize color indicators
  1237.  
  1238. lod_x:    bsr    clos_file
  1239. lod_x2:    bra    ortn_exit
  1240.  
  1241. lseek:    move    #0,-(sp)
  1242.     move.w    fhandl,-(sp)
  1243.     move.l    d0,-(sp)
  1244.     move.w    #$42,-(sp)
  1245.     trap    #1
  1246.     add    #10,sp
  1247.     tst.l    d0
  1248.     rts
  1249.  
  1250. clr_mask:
  1251.     bsr    copy_mouse    ; Save in undo buffer
  1252.     move.l    #m_mask,a5    ; Address of mask
  1253.     bra.s    clr2
  1254.  
  1255. clr_data:
  1256.     bsr    copy_mouse    ; Save mouse
  1257.     move.l    #m_image,a5    ; Address of data
  1258. clr2:    move    #7,d5        ; 8 longwords (16 words)
  1259. clrd1:    clr.l    (a5)+        ; Clear that mouse!
  1260.     dbf    d5,clrd1
  1261.     bsr    map_grid    ; Draw it on the grid
  1262.     bra    ortn_exit
  1263.  
  1264. inv_data:
  1265.     bsr    copy_mouse
  1266.     move.l    #m_image,a5
  1267.     bra.s    inv2
  1268.  
  1269. inv_mask:
  1270.     bsr    copy_mouse
  1271.     move.l    #m_mask,a5
  1272. inv2:    move    #15,d5        ; 16 words
  1273. invm1:    eor.w    #$FFFF,(a5)+    ; Invert every bit in each word
  1274.     dbf    d5,invm1
  1275.     bsr    map_grid    ; Draw it on the grid
  1276.     bra    ortn_exit
  1277.  
  1278. mir_data:
  1279.     bsr    copy_mouse
  1280.     move.l    #m_image,a5
  1281.     bra.s    mir2
  1282.  
  1283. mir_mask:
  1284.     bsr    copy_mouse
  1285.     move.l    #m_mask,a5
  1286. mir2:    move    #15,d5        ; 16 words of mouse data
  1287. mir3:    move    #15,d4        ; 16 bits in each word
  1288.     clr.w    d1        ; Clear work register
  1289.     move    (a5),d0        ; Get the word
  1290. mirm1:    lsl    d0        ; Shift a bit left
  1291.     roxr    d1        ; Roll it right into the work register
  1292.     dbf    d4,mirm1    ; Do all 16 bits
  1293.     move    d1,(a5)+    ; Put it back
  1294.     dbf    d5,mir3        ; Do all 16 words
  1295.     bsr    map_grid    ; Draw the grid
  1296.     bra    ortn_exit
  1297.  
  1298. rotate:
  1299.     bsr    copy_mouse    ; Save in undo buffer
  1300.     move.l    #m_rotate,a5    ; Address of rotation buffer
  1301.     move    #15,d5
  1302. r_clr:    clr.l    (a5)+        ; First, clear out the rotation buffer
  1303.     dbf    d5,r_clr
  1304.     move.l    #m_mask+30,a4    ; Start at end of data
  1305.     move.l    #m_rotate,a5
  1306. r_lp1:    move    #15,d4        ; 16 words
  1307. wordlp:    move    (a4),d2        ; Get a word
  1308.     move    #15,d5        ; 16 bits per word
  1309. bitloo:    move    d5,d3        ; Get bit number
  1310.     lsl    d3        ; Multiply by 2 (for word offset)
  1311.     move    0(a5,d3),d1    ; Get word from rotation buffer
  1312.     lsr    d2        ; Shift a bit right
  1313.     roxl    d1        ; Roll it left into d1
  1314.     move    d1,0(a5,d3)    ; Put this new word back
  1315.     dbf    d5,bitloo    ; Do all 16 bits
  1316.     subq.w    #2,a4        ; Point to next data word
  1317.     dbf    d4,wordlp    ; Do all 16 words
  1318.     cmp.l    #m_mask-2,a4    ; We're rotating both mask and data together
  1319.     bne.s    r_cpy1        ; All done, skip ahead
  1320.     move.l    #m_mask+62,a4    ; Set address of mask
  1321.     move.l    #m_rotate+32,a5
  1322.     bra    r_lp1        ; Go finish the job
  1323.  
  1324. r_cpy1:    move.l    #m_mask,a4
  1325.     move.l    #m_rotate,a5
  1326.     move    #15,d5
  1327. r_cpy:    move.l    (a5)+,(a4)+    ; Move the mouse data from the rotation buffer
  1328.     dbf    d5,r_cpy
  1329.     bsr    map_grid    ; Draw the grid
  1330.     bra    ortn_exit
  1331.  
  1332. up:
  1333.     bsr    copy_mouse    ; Scroll mouse image up
  1334.     move.l    #m_image,a5    ; First, the data
  1335.     move    (a5),temp    ; Save top word
  1336.     move    #14,d5
  1337. up1:    move    2(a5),(a5)+    ; Move 'em up
  1338.     dbf    d5,up1
  1339.     move    temp,(a5)    ; Put the top line in at the bottom
  1340.     move.l    #m_mask,a5    ; Now do the mask
  1341.     move    (a5),temp
  1342.     move    #14,d5
  1343. up2:    move    2(a5),(a5)+    ; Get on up!
  1344.     dbf    d5,up2
  1345.     move    temp,(a5)
  1346.     bsr    map_grid    ; Draw the grid
  1347.     bra    ortn_exit
  1348.  
  1349. left:
  1350.     bsr    copy_mouse    ; Scroll mouse form left
  1351.     move.l    #m_mask,a5
  1352.     move    #31,d5
  1353. left1:    lsl    (a5)+        ; Shift a bit left
  1354.     bcc.s    left2        ; This bit wasn't set, skip ahead
  1355.     or.w    #1,-2(a5)    ; Set rightmost bit
  1356. left2:    dbf    d5,left1
  1357.     bsr    map_grid
  1358.     bra    ortn_exit
  1359.  
  1360. down:
  1361.     bsr    copy_mouse    ; Scroll mouse shape down
  1362.     move.l    #m_image+30,a5    ; First, the data
  1363.     move    (a5),temp    ; Save bottom word
  1364.     move    #14,d5
  1365. down1:    move    -2(a5),(a5)    ; Get down!
  1366.     subq    #2,a5
  1367.     dbf    d5,down1
  1368.     move    temp,(a5)    ; Put bottom word at the top
  1369.     move.l    #m_mask+30,a5    ; Now do the same for the mask
  1370.     move    (a5),temp
  1371.     move    #14,d5
  1372. down2:    move    -2(a5),(a5)
  1373.     subq    #2,a5
  1374.     dbf    d5,down2
  1375.     move    temp,(a5)
  1376.     bsr    map_grid
  1377.     bra    ortn_exit
  1378.  
  1379. right:
  1380.     bsr    copy_mouse    ; Scroll mouse image right
  1381.     move.l    #m_mask,a5
  1382.     move    #31,d5
  1383. right1:    lsr    (a5)+        ; Shift a bit
  1384.     bcc.s    right2        ; It wasn't set, skip
  1385.     or.w    #$8000,-2(a5)    ; Set leftmost bit in this word
  1386. right2:    dbf    d5,right1
  1387.     bsr    map_grid
  1388.     bra    ortn_exit
  1389.  
  1390. install:
  1391.     move.l    #m_mask,a5    ; Don't let 'em install a blank mouse!
  1392.     move    #15,d5
  1393. ck_i1:    tst.l    (a5)+
  1394.     bne.s    inst1
  1395.     dbf    d5,ck_i1
  1396.     bra.s    instx
  1397. inst1:    bsr    cpy_inst    ; Copy mouse to 'Installed' area
  1398.     move.l    #g_mous,aespb    ; AES graf_mouse call to set the new image
  1399.     move    #255,intin
  1400.     move.l    #m_form2,addrin
  1401.     bsr    aes
  1402.     move    #1,insflg    ; Set installed flag
  1403.     move    #1,vbi_on    ; Turn on the vertical blank interrupt
  1404. instx:    bra    ortn_exit
  1405.  
  1406. remove:
  1407.     clr.w    insflg        ; Clear installed flag
  1408.     clr.w    vbi_on        ; Remove vertical blank routine
  1409.  
  1410.     move.l    #g_mous,aespb    ; Set the arrow cursor
  1411.     clr.w    intin
  1412.     bsr    aes
  1413.     bra    ortn_exit
  1414.  
  1415. undo:
  1416.     bsr    res_mouse    ; Restore mouse data from the undo buffer
  1417.     bsr    map_grid    ; Draw it on the grid
  1418.     bra    ortn_exit
  1419.  
  1420. colr_down:
  1421.     tst.w    colflg        ; Which color? Data or mask?
  1422.     bne.s    cd_1        ; Must be the mask color, skip ahead
  1423.     tst.w    bg_col        ; Is it zero already?
  1424.     beq    ortn_exit    ; Yes, bail
  1425.     subq.w    #1,bg_col    ; Decrement it
  1426.     move.l    #dvalms,a5    ; Address of color value text
  1427.     bra.s    cd_2        ; Skip
  1428. cd_1:    tst.w    fg_col        ; Zero already?
  1429.     beq    ortn_exit    ; Yes, forget it
  1430.     subq.w    #1,fg_col    ; Decrement it
  1431.     move.l    #mvalms,a5    ; Address of color value text
  1432. cd_2:    move.l    #1,d5        ; Two digits
  1433.     add.l    d5,a5        ; Set pointer 2nd digit (ones place)
  1434. dnloop:    cmp.b    #'0',(a5)    ; Is it ASCII zero?
  1435.     bne.s    dnl2        ; No, skip ahead
  1436.     move.b    #'9',(a5)    ; Put a '9' here
  1437.     bra.s    dnl3
  1438. dnl2:    subq.b    #1,(a5)        ; Decrement the ASCII number
  1439.     bra.s    valdrw        ; Go draw it
  1440. dnl3:    subq    #1,a5        ; Move pointer to tens digit
  1441.     dbf    d5,dnloop
  1442.     bra.s    valdrw
  1443.  
  1444. colr_up:
  1445.     tst.w    colflg        ; This code does the same thing as the section
  1446.     bne.s    cu_1        ; above, but for color-up adjustments
  1447.     cmp.w    #15,bg_col
  1448.     beq    ortn_exit
  1449.     addq.w    #1,bg_col
  1450.     move.l    #dvalms,a5
  1451.     bra.s    cu_2
  1452. cu_1:    cmp.w    #15,fg_col
  1453.     beq    ortn_exit
  1454.     addq.w    #1,fg_col
  1455.     move.l    #mvalms,a5
  1456. cu_2:    move.l    #1,d5
  1457.     add.l    d5,a5
  1458. uploop:    cmp.b    #'9',(a5)
  1459.     bne.s    upl2
  1460.     move.b    #'0',(a5)
  1461.     bra.s    upl3
  1462. upl2:    addq.b    #1,(a5)
  1463.     bra.s    valdrw
  1464. upl3:    subq    #1,a5
  1465.     dbf    d5,uploop
  1466. valdrw:    move    #colval,intin    ; Object index of the color value text
  1467.     move.l    #editbx,addrin    ; Address of object tree
  1468.     bsr    objoff        ; Go draw this text object
  1469.     bra    ortn_exit
  1470.  
  1471. sw_fgbg:
  1472.     eor.w    #1,colflg    ; Toggle color flag
  1473.     tst.w    colflg        ; Which color, mask or data?
  1474.     beq.s    sw_1        ; 0=data, 1=mask
  1475.     move.l    #mcolms,tinf3    ; Set pointers to text strings
  1476.     move.l    #mvalms,valadr
  1477.     bra.s    sw_2
  1478. sw_1:    move.l    #dcolms,tinf3
  1479.     move.l    #dvalms,valadr
  1480. sw_2:    move    #colttl,intin    ; And go draw the object
  1481.     move.l    #editbx,addrin
  1482.     bsr    objoff
  1483.     bra    valdrw
  1484.  
  1485. sw_anttl:
  1486.     addq.w    #1,antflg    ; Increment flag
  1487.     move.w    antflg,d0
  1488.     cmp.w    #3,d0        ; Greater than 2?
  1489.     bne.s    swa_1
  1490.     sub.w    d0,d0        ; Back to zero
  1491.     move.w    d0,antflg
  1492. swa_1:    tst    d0        ; 0=Frame, 1=# of Frames, 2=Speed
  1493.     bne.s    swa_2
  1494.     move.l    #framms,tinf4
  1495.     move.l    #frvlms,anival
  1496.     bra.s    swa_4
  1497. swa_2:    cmp.w    #1,d0
  1498.     bne.s    swa_3
  1499.     move.l    #frmnms,tinf4
  1500.     move.l    #fnvlms,anival
  1501.     bra.s    swa_4
  1502. swa_3:    move.l    #speems,tinf4
  1503.     move.l    #spvlms,anival
  1504. swa_4:    move.w    #frmttl,intin
  1505.     move.l    #editbx,addrin
  1506.     bsr    objoff
  1507.     move.w    #frmval,intin
  1508.     move.l    #editbx,addrin
  1509.     bsr    objoff
  1510.     bra    ortn_exit
  1511.  
  1512. ani_down:
  1513.     tst    antflg        ; Are we changing the frame?
  1514.     bne.s    anid_2        ; No, skip ahead
  1515.     bsr    chk_shift
  1516.     bsr    frm_2_arr    ; Copy current frame to sequence array
  1517.     tst    franum        ; Is it zero already?
  1518.     bne.s    d_fnum
  1519.     move.b    #'3',frvlms
  1520.     move.b    #'2',frvlms+1
  1521.     move.w    #31,franum
  1522.     bra    fvaldr
  1523. d_fnum:    subq.w    #1,franum
  1524.     move.l    #frvlms,a5
  1525.     bra.s    ad_1
  1526. anid_2:    cmp.w    #1,antflg    ; Changing # of Frames?
  1527.     bne.s    anid_3
  1528.     cmp.w    #1,nframs
  1529.     bne.s    d_nfrm
  1530.     move.b    #'3',fnvlms
  1531.     move.b    #'2',fnvlms+1
  1532.     move.w    #32,nframs
  1533.     bra.s    fvaldr
  1534. d_nfrm:    subq.w    #1,nframs
  1535.     move.l    #fnvlms,a5
  1536.     bra.s    ad_1
  1537. anid_3:    tst    delval        ; Must be changing the delay value
  1538.     bne.s    d_delv
  1539.     move.b    #'9',spvlms
  1540.     move.b    #'9',spvlms+1
  1541.     move.w    #99,delval
  1542.     bra.s    fvaldr
  1543. d_delv:    subq.w    #1,delval
  1544.     move.l    #spvlms,a5
  1545. ad_1:    move.l    #1,d5
  1546.     add.l    d5,a5
  1547. adloop:    cmp.b    #'0',(a5)    ; Is it ASCII zero?
  1548.     bne.s    adl2
  1549.     move.b    #'9',(a5)
  1550.     bra.s    adl3
  1551. adl2:    subq.b    #1,(a5)        ; Decrement the ASCII number
  1552.     bra.s    fvaldr
  1553. adl3:    subq    #1,a5        ; Move pointer to tens digit
  1554.     dbf    d5,adloop
  1555. fvaldr:    move.w    #frmval,intin
  1556.     move.l    #editbx,addrin
  1557.     bsr    objoff
  1558.     tst    antflg        ; Changing current frame?
  1559.     beq.s    fvald1        ; Yes, skip
  1560.     move    #7,d5
  1561. waitnd:    move.w    #37,-(sp)    ; Wait 6 vertical blanks
  1562.     trap    #14        ; (in case button is being held)
  1563.     addq    #2,sp
  1564.     dbf    d5,waitnd
  1565.     bra    ortn_exit
  1566. fvald1:    tst    shfflg        ; Were we holding shift (copying)?
  1567.     beq.s    fvald2        ; No, skip
  1568.     bsr    frm_2_arr    ; Copy mouse form to new array position
  1569. fvald2:    bsr    arr_2_frm    ; Copy it back (dumb)
  1570.     bsr    init_col
  1571.     move.w    #colval,intin
  1572.     move.l    #editbx,addrin
  1573.     bsr    objoff
  1574.     bsr    map_grid
  1575. fvex:    bra    ortn_exit
  1576.  
  1577. ani_up:
  1578.     tst    antflg
  1579.     bne.s    aniu_2
  1580.     bsr    chk_shift
  1581.     bsr    frm_2_arr
  1582.     cmp.w    #31,franum
  1583.     bne.s    i_fnum
  1584.     move.b    #'0',frvlms
  1585.     move.b    #'1',frvlms+1
  1586.     clr.w    franum
  1587.     bra    fvaldr
  1588. i_fnum:    addq.w    #1,franum
  1589.     move.l    #frvlms,a5
  1590.     bra.s    au_1
  1591. aniu_2:    cmp.w    #1,antflg
  1592.     bne.s    aniu_3
  1593.     cmp.w    #32,nframs
  1594.     bne.s    i_nfrm
  1595.     move.b    #'0',fnvlms
  1596.     move.b    #'1',fnvlms+1
  1597.     move.w    #1,nframs
  1598.     bra    fvaldr
  1599. i_nfrm:    addq.w    #1,nframs
  1600.     move.l    #fnvlms,a5
  1601.     bra.s    au_1
  1602. aniu_3:    cmp.w    #99,delval
  1603.     bne.s    i_delv
  1604.     move.b    #'0',spvlms
  1605.     move.b    #'0',spvlms+1
  1606.     clr.w    delval
  1607.     bra    fvaldr
  1608. i_delv:    addq.w    #1,delval
  1609.     move.l    #spvlms,a5
  1610. au_1:    move.l    #1,d5
  1611.     add.l    d5,a5
  1612. auloop:    cmp.b    #'9',(a5)
  1613.     bne.s    aul2
  1614.     move.b    #'0',(a5)
  1615.     bra.s    aul3
  1616. aul2:    addq.b    #1,(a5)
  1617.     bra    fvaldr
  1618. aul3:    subq    #1,a5
  1619.     dbf    d5,auloop
  1620.     bra    fvaldr
  1621.  
  1622. * Subroutines for ani_up and ani_down
  1623.  
  1624. chk_shift:
  1625.     clr.w    shfflg
  1626.     move.w    #-1,-(sp)    ; Get Alt/Shift/Control status
  1627.     move.w    #11,-(sp)
  1628.     trap    #13
  1629.     addq    #4,sp
  1630.     btst    #0,d0        ; Right shift key?
  1631.     bne.s    shift1
  1632.     btst    #1,d0        ; Left shift key?
  1633.     beq.s    shift2
  1634. shift1:    move    #1,shfflg
  1635. shift2:    rts
  1636.  
  1637. frm_2_arr:
  1638.     bsr.s    set_faadr
  1639. cpyfr1:    move.l    (a1)+,(a0)+
  1640.     dbf    d0,cpyfr1
  1641.     move.w    (a1),(a0)    ; Move last word to make it 74
  1642.     rts
  1643.  
  1644. arr_2_frm:
  1645.     bsr.s    set_faadr
  1646. cpyar1:    move.l    (a0)+,(a1)+
  1647.     dbf    d0,cpyar1
  1648.     move.w    (a0),(a1)
  1649.     bra    copy_mouse
  1650.  
  1651. set_faadr:
  1652.     move.l    #mouse_array,a0    ; Address of animation array
  1653.     moveq    #0,d0        ; Clear work register
  1654.     move.w    franum,d0    ; Get current frame number
  1655.     mulu    #74,d0        ; Multiply by 74 (74 bytes per mouse)
  1656.     add.l    d0,a0        ; Add index to pointer
  1657.     move.w    #17,d0
  1658.     move.l    #mouse_form,a1
  1659.     rts
  1660.  
  1661. clear_array:
  1662.     move.l    #mouse_array,a0
  1663.     move    #591,d0
  1664. cla_1:    clr.l    (a0)+
  1665.     dbf    d0,cla_1
  1666.     rts
  1667.  
  1668. ani_onoff:
  1669.     tst    onoff        ; Is animation on or off?
  1670.     bne.s    anio_2        ; It's on, skip ahead
  1671.     bsr    frm_2_arr    ; Copy current frame to animation buffer
  1672.     move.l    #anonms,tinf5    ; Set "Animation ON" message
  1673.     move.w    delval,vbtimr    ; Set the vertical blank timer
  1674.     clr.w    moucnt        ; Clear the frame counter
  1675.     move    #1,onoff    ; Now set the animation flag
  1676.     bra.s    anio_3
  1677. anio_2:    move.l    #anofms,tinf5    ; Set "Animation OFF" message
  1678.     clr.w    moucnt        ; Clear the frame counter
  1679.     clr.w    onoff        ; Clear the animation flag
  1680.     tst    insflg        ; Are we installed?
  1681.     beq.s    anio_3        ; No, skip ahead
  1682.     move.l    #g_mous,aespb    ; Set mouse form back to installed shape
  1683.     move    #255,intin
  1684.     move.l    #m_form2,addrin
  1685.     bsr    aes
  1686.  
  1687. anio_3:    move.w    #anonof,intin    ; Re-draw the ON/OFF message box
  1688.     move.l    #editbx,addrin
  1689.     bsr    objoff
  1690. *    bra.s    ortn_exit
  1691.  
  1692. * All object routines exit through here
  1693.  
  1694. ortn_exit:
  1695.     tst.w    butflg
  1696.     beq    the_big_loop
  1697.  
  1698.     move.w    o_indx,d0
  1699.     cmp.w    #cdowbt,d0    ; If it was 'down', 'up', or color selection,
  1700.     beq    the_big_loop    ; loop back right away
  1701.     cmp.w    #cupbt,d0
  1702.     beq    the_big_loop
  1703.     cmp.w    #colttl,d0
  1704.     beq    the_big_loop
  1705.     cmp.w    #frmttl,d0
  1706.     beq    the_big_loop
  1707.     cmp.w    #frdown,d0
  1708.     beq    the_big_loop
  1709.     cmp.w    #frup,d0
  1710.     beq    the_big_loop
  1711.     cmp.w    #anonof,d0
  1712.     beq    the_big_loop
  1713.  
  1714.     move.l    o_asav,a0    ; Get address of object that was selected
  1715.     and.w    #$FFFE,10(a0)    ; De-select it
  1716.     tst.w    numrtn        ; If it was 'Save' or 'Load', go back to
  1717.     beq    box        ; the dialog box drawing code
  1718.     cmp.w    #1,numrtn
  1719.     beq    box
  1720.     bsr    obdraw        ; Go re-draw the object
  1721.     bra    the_big_loop    ; Back to the top of the loop
  1722.  
  1723. ckchng:    cmp.w    #434,mousex    ; Check to see if we're inside the
  1724.     blt.s    ckbutt        ; mouse-change rectangle
  1725.     cmp.w    #515,mousex
  1726.     bgt.s    ckbutt
  1727.     move    mousey,d0
  1728.     cmp.w    y_off,d0
  1729.     blt.s    ckbutt
  1730.     cmp.w    chang1,d0
  1731.     bgt.s    ckbutt
  1732.     tst.w    m_flag        ; Were we already in here?
  1733.     bne    the_big_loop    ; Yes! Go back
  1734.     move.l    #m_mask,a0
  1735.     move    #15,d0
  1736. ck_img:    tst.l    (a0)+        ; If the mouse data is all zeros, don't
  1737.     bne.s    setmou        ; change it
  1738.     dbf    d0,ck_img
  1739.     bra    the_big_loop
  1740. setmou:    clr.w    vbi_on        ; Turn off the interrupt while we're here
  1741.     move    #1,m_flag    ; Set the flag
  1742.     move.l    #g_mous,aespb    ; Change the mouse form
  1743.     move    #255,intin
  1744.     move.l    #mouse_form,addrin
  1745.     bsr    aes
  1746.     bra    the_big_loop
  1747.  
  1748. ckbutt:    tst.w    m_flag        ; Just leaving the mouse-change rectangle?
  1749.     beq.s    ckb2        ; No, skip
  1750.     move.l    #g_mous,aespb
  1751.     move    #255,intin
  1752.     tst.w    insflg        ; Mouse form installed?
  1753.     bne.s    ckbu1        ; Yes, skip
  1754.     clr.w    intin
  1755.     bra.s    arr2
  1756. ckbu1:    move    #1,vbi_on
  1757.     tst    onoff
  1758.     beq.s    ckbu2
  1759.     bsr    which_mouse
  1760.     move.l    a3,addrin
  1761.     bra.s    arr2
  1762. ckbu2:    move.l    #m_form2,addrin
  1763. arr2:    bsr    aes
  1764.     clr.w    m_flag
  1765.  
  1766. ckb2:    btst    #0,butsav    ; Left button pressed?
  1767.     bne.s    ckpos        ; Yes, go check position
  1768.     btst    #1,butsav    ; Right button?
  1769.     bne.s    ckpos
  1770.     tst.w    d_flag        ; Were we just drawing?
  1771.     beq    the_big_loop    ; No, forget it
  1772.     clr.w    d_flag        ; Clear the flag
  1773.     bra    the_big_loop
  1774.  
  1775. ckpos:    tst.w    d_flag        ; OK, we're drawing - is the draw flag set?
  1776.     bne.s    ckp1        ; Yes, so skip ahead
  1777.     bsr    copy_mouse    ; Copy mouse shape to undo buffer
  1778.     move    #1,d_flag    ; Set draw flag
  1779. ckp1:    move    mousey,d0    ; Get Y position
  1780.     cmp.w    y_off,d0    ; Is mouse Y >= 100/50?
  1781.     blt    the_big_loop
  1782.     cmp.w    y_bot,d0    ; Is it < 260/130?
  1783.     bge    the_big_loop
  1784.  
  1785.     bsr    inquire        ; Go see which grid is being drawn on
  1786.     bra    the_big_loop    ; And back to the top
  1787.  
  1788. exit:    move    d_mode,intin    ; Reset all the polyline and fill
  1789.     bsr    write_mode    ; attributes
  1790.     move    l_colr,intin
  1791.     bsr    poly_color
  1792.     move    l_type,intin
  1793.     bsr    poly_type
  1794.     move    l_wid,ptsin
  1795.     clr.w    ptsin+2
  1796.     bsr    poly_width
  1797.     move    l_strt,intin
  1798.     move    l_end,intin+2
  1799.     bsr    poly_ends
  1800.     move    f_type,intin
  1801.     bsr    vsf_interior
  1802.     move    f_colr,intin
  1803.     bsr    vsf_color
  1804.     move    f_patt,intin
  1805.     bsr    vsf_style
  1806.  
  1807.     move    #3,intin    ; Release dialog box memory
  1808.     bsr    dial
  1809.  
  1810.     move.l    #w_clos,aespb    ; Close window so the application gets a
  1811.     move    whandl,intin    ; redraw message
  1812.     bsr    aes
  1813.     move.l    #w_del,aespb    ; Now delete the window
  1814.     bsr    aes
  1815.  
  1816.     move.l    #w_updt,aespb    ; Allow messages again
  1817.     clr.w    intin
  1818.     bsr    aes
  1819.  
  1820. ex2:    bsr    repl_button    ; Replace the system button vector
  1821.  
  1822.     move    #101,(a5)    ; v_clsvwk (Close Virtual Workstation)
  1823.     clr.w    2(a5)
  1824.     clr.w    6(a5)
  1825.     bsr    vdi
  1826.  
  1827.     bsr    res_dpath    ; Reset drive and pathname
  1828.  
  1829.     and.w    #$FFFE,extstt    ; Reset EXIT button
  1830.  
  1831.     clr    diflag
  1832.  
  1833.     bra    evntms        ; Go back and wait for another message!
  1834.  
  1835.  
  1836. * Subroutines
  1837.  
  1838. inquire:
  1839.     move    #0,hotflg    ; Clear hotspot flag
  1840.  
  1841.     cmp.w    #50,mousex    ; Are we inside the data grid?
  1842.     blt    inq_return    ; No, exit
  1843.     cmp.w    #209,mousex
  1844.     bge    inq_2        ; Go check to see if we're over the mask grid
  1845.  
  1846.     moveq    #0,d0        ; Clear work register
  1847.     move    mousex,d0    ; Get mouse X position
  1848.     sub.w    #50,d0        ; The data grid starts 50 pixels from the left
  1849.     divu    #10,d0        ; Divide by 10 to get cell X
  1850.     bvc.s    storx        ; No overflow, skip
  1851.     sub.w    d0,d0        ; Set it to zero
  1852. storx:    move    d0,x        ; Set X array index
  1853.     moveq    #0,d0        ; Clear register
  1854.     move    mousey,d0    ; Get mouse Y position
  1855.     sub.w    y_off,d0    ; Subtract res-dependent offset value
  1856.     divu    y_div,d0    ; Divide by res-dependent Y divisor
  1857.     bvc.s    story        ; No overflow, skip
  1858.     sub.w    d0,d0        ; Clear it
  1859. story:    move    d0,y        ; Set Y array index
  1860.  
  1861.     btst    #0,butsav    ; Was the left button pressed?
  1862.     beq.s    eras_1        ; No, go to the erase routine
  1863.     btst    #1,butsav    ; Right button?
  1864.     beq.s    inq1_1        ; No, skip
  1865. do_hot:    bsr    sample_mouse    ; Read mouse status
  1866.     btst    #0,intout+1    ; Still pressing the left button?
  1867.     bne    do_hot        ; Yes, loop
  1868.     btst    #1,intout+1    ; Still pressing right?
  1869.     bne    do_hot        ; Yes, loop
  1870.     move.l    x,temp        ; Save current x index
  1871.     move.l    x_hot,x        ; Set x index to hotspot position
  1872.     move    #1,hotflg    ; Set hotspot flag
  1873.     dc.w    $A00A        ; Hide the mouse
  1874.     bsr    draw_pixel    ; Go draw the hotspot
  1875.     bsr    show_mouse    ; Show the mouse
  1876.     move.l    temp,x_hot    ; Replace x position
  1877.     bsr    set_hotspot
  1878.     rts
  1879.  
  1880. inq1_1:    move.w    #-1,-(sp)
  1881.     move.w    #11,-(sp)
  1882.     trap    #13
  1883.     addq    #4,sp
  1884.     btst    #2,d0        ; Control key pressed?
  1885.     bne    do_hot        ; Yes, do the hot spot
  1886.     bsr    get_iptr    ; Get pointer to element of data array
  1887.     bne.s    inq_return    ; Return if not zero
  1888.     bset    d0,d1        ; Set this bit
  1889.     move    d1,(a0)        ; And store it into the mouse shape area
  1890.     bra.s    godraw
  1891.  
  1892. eras_1:    btst    #1,butsav    ; Right button?
  1893.     beq.s    godraw        ; No, skip
  1894.  
  1895.     bsr    get_iptr    ; Get pointer to data element
  1896.     beq.s    inq_return    ; Zero, exit
  1897.     bclr    d0,d1        ; Clear this bit
  1898.     move    d1,(a0)        ; And store the word
  1899.  
  1900. godraw:    dc.w    $A00A        ; Hide the mouse
  1901.     bsr    draw_pixel    ; Go draw the pixel on the data grid
  1902.     bsr    show_mouse    ; Show the mouse again
  1903. inq_return:
  1904.     rts
  1905.  
  1906. inq_2:
  1907.     cmp.w    #250,mousex    ; Are we inside the mask grid?
  1908.     blt    inq_return
  1909.     cmp.w    #409,mousex
  1910.     bge    inq_return
  1911.  
  1912.     moveq    #0,d0        ; Clear the work register
  1913.     move    mousex,d0    ; Get X position
  1914.     sub.w    #250,d0        ; Mask grid starts 250 pixels from the left
  1915.     divu    #10,d0        ; Each cell is 10 pixels wide
  1916.     bvc.s    storx2        ; No overflow, skip
  1917.     sub.w    d0,d0        ; Clear it
  1918. storx2:    move    d0,x        ; Save X index to array
  1919.     moveq    #0,d0        ; Clear register
  1920.     move    mousey,d0    ; Get Y position
  1921.     sub.w    y_off,d0    ; Subtract res-dependent offset value
  1922.     divu    y_div,d0    ; Divide by res-dependent Y divisor
  1923.     bvc.s    story2        ; No overflow, skip
  1924.     sub.w    d0,d0        ; Clear y index
  1925. story2:    move    d0,y        ; Save Y array index
  1926.  
  1927.     btst    #0,butsav    ; Left button?
  1928.     beq.s    eras_2        ; No, go erase
  1929.  
  1930.     bsr    get_mptr    ; Get pointer to mask bit
  1931.     bne    inq_return    ; Already set, exit
  1932.     bset    d0,d1        ; Set this bit in the mouse mask
  1933.     move    d1,(a0)        ; And save it
  1934.     bra    godraw
  1935.  
  1936. eras_2:    btst    #1,butsav    ; Right button?
  1937.     beq    godraw        ; No, bail
  1938.  
  1939.     bsr    get_mptr    ; Find the bit and clear it
  1940.     beq    inq_return    ; (if it isn't already zero)
  1941.     bclr    d0,d1
  1942.     move    d1,(a0)
  1943.     bra    godraw
  1944.  
  1945. map_grid:
  1946.     dc.w    $A00A        ; Hide mouse
  1947.     move    #1,hotflg    ; Set hotspot flag
  1948.     move    #15,d5        ; Draw both grids
  1949. map1:    move    #15,d4
  1950. map2:    move    d5,x
  1951.     move    d4,y
  1952.     bsr.s    draw_pixel
  1953.     dbf    d4,map2
  1954.     dbf    d5,map1
  1955.     bsr    set_hotspot    ; Draw the hotspot
  1956.     bsr    show_mouse    ; Show the mouse again
  1957.     rts
  1958.  
  1959. copy_mouse:
  1960.     move.l    x_hot,hotsav    ; Copy the mouse shape to the undo buffer
  1961.     move.l    #m_mask,a0
  1962.     move.l    #mouse_save,a1
  1963.     move    #15,d0
  1964. cpym2:    move.l    (a0)+,(a1)+
  1965.     dbf    d0,cpym2
  1966.     rts
  1967.  
  1968. res_mouse:
  1969.     move.l    hotsav,x_hot    ; Restore the mouse shape from the undo buffer
  1970.     move.l    #m_mask,a0
  1971.     move.l    #mouse_save,a1
  1972.     move    #15,d0
  1973. resm2:    move.l    (a1)+,(a0)+
  1974.     dbf    d0,resm2
  1975.     rts
  1976.  
  1977. draw_pixel:
  1978.     bsr    get_iptr    ; Is this data bit set?
  1979.     bne.s    solid        ; Yes, skip ahead
  1980.  
  1981.     bsr    get_mptr    ; Is this mask bit set?
  1982.     bne.s    blank2        ; Yes, skip ahead
  1983.  
  1984.     move.l    #empty,filptr
  1985.     bsr.s    d_int1        ; Draw the data cell
  1986.     bsr    d_int2        ; Draw the mask cell
  1987.  
  1988.     bra.s    draw_exit
  1989.  
  1990. blank2:    move.l    #dots,filptr
  1991.     bsr.s    d_int1        ; Draw the data cell
  1992.     bsr    d_int2        ; Draw the mask cell
  1993.  
  1994.     bra.s    draw_exit
  1995.  
  1996. solid:    bsr    get_mptr    ; Is this mask bit set?
  1997.     bne.s    solid2        ; Yes, skip
  1998.  
  1999.     move.l    #black,filptr
  2000.  
  2001.     bsr.s    d_int1        ; Draw the data cell
  2002.     bsr    d_int2        ; Draw the mask cell
  2003.  
  2004.     bra.s    draw_exit
  2005.  
  2006. solid2:    move.l    #black,filptr
  2007.     bsr.s    d_int1        ; Draw the data cell
  2008.     move.l    #dots,filptr
  2009.     bsr    d_int2        ; Draw the mask cell
  2010.  
  2011. draw_exit:
  2012.     tst.w    hotflg        ; Time to draw the hotspot?
  2013.     bne.s    d_ex2        ; No, skip
  2014.     bsr    set_hotspot    ; Draw that hotspot
  2015. d_ex2:    rts
  2016.  
  2017. d_int1:
  2018.     move.l    screen,a0    ; Get address of screen memory
  2019.     moveq    #0,d0
  2020.     move    y,d0
  2021.     mulu    y_div,d0
  2022.     add.w    y_off,d0
  2023.     addq.w    #1,d0
  2024.     mulu    y_scr,d0
  2025.     add.l    d0,a0        ; Set pointer to proper scan line
  2026.     moveq    #0,d0
  2027.     move.w    x,d0
  2028.     mulu    #10,d0
  2029.     add.w    #51,d0
  2030. di1_0:    divu    #16,d0
  2031.     cmp.w    #2,res        ; High res?
  2032.     bne.s    col_di
  2033.     lsl.w    d0
  2034.     move.l    d0,d1
  2035.     swap    d1        ; Get remainder to lower word
  2036.     ext.l    d1
  2037.     move.l    filptr,a1
  2038.     move    #8,d3        ; Use d3 as counter (9 scan lines)
  2039.  
  2040. di1_1:    moveq    #0,d2        ; Clear d2
  2041.     move.w    (a1),d2        ; Get first line of fill pattern
  2042.     swap    d2
  2043.     move.l    #$007FFFFF,d7    ; Mask to d7
  2044.     lsr.l    d1,d2
  2045.     or    #16,ccr
  2046.     roxr.l    d1,d7
  2047.     and.l    d7,0(a0,d0)
  2048.     or.l    d2,0(a0,d0)
  2049.     add.l    #80,a0
  2050.     subq.w    #1,d3
  2051.     bmi.s    di1ex
  2052.     moveq    #0,d2
  2053.     move.w    2(a1),d2    ; Second line of fill pattern
  2054.     swap    d2
  2055.     move.l    #$007FFFFF,d7    ; Mask to d7
  2056.     lsr.l    d1,d2
  2057.     or    #16,ccr
  2058.     roxr.l    d1,d7
  2059.     and.l    d7,0(a0,d0)
  2060.     or.l    d2,0(a0,d0)
  2061.     add.l    #80,a0
  2062.     dbf    d3,di1_1
  2063. di1ex:    rts
  2064.  
  2065. col_di:
  2066.     lsl.w    #2,d0
  2067.     move.l    d0,d1
  2068.     swap    d1
  2069.     ext.l    d1
  2070.     move.l    filptr,a1
  2071.     move    #3,d3
  2072.  
  2073. col1_1:    moveq    #0,d2
  2074.     move.w    4(a1),d2
  2075.     swap    d2
  2076.     move.l    #$007FFFFF,d7
  2077.     lsr.l    d1,d2
  2078.     or    #16,ccr
  2079.     roxr.l    d1,d7
  2080.     and.w    d7,4(a0,d0)
  2081.     and.w    d7,6(a0,d0)
  2082.     swap    d7
  2083.     and.w    d7,0(a0,d0)
  2084.     and.w    d7,2(a0,d0)
  2085.     or.w    d2,4(a0,d0)
  2086.     swap    d2
  2087.     or.w    d2,0(a0,d0)
  2088.     moveq    #0,d2
  2089.     move.w    6(a1),d2
  2090.     swap    d2
  2091.     lsr.l    d1,d2
  2092.     or.w    d2,6(a0,d0)
  2093.     swap    d2
  2094.     or.w    d2,2(a0,d0)
  2095.     add.l    #160,a0
  2096.     dbf    d3,col1_1
  2097.     rts
  2098.  
  2099. d_int2:
  2100.     move.l    screen,a0    ; Get address of screen memory
  2101.     moveq    #0,d0
  2102.     move    y,d0
  2103.     mulu    y_div,d0
  2104.     add.w    y_off,d0
  2105.     addq.w    #1,d0
  2106.     mulu    y_scr,d0
  2107.     add.l    d0,a0        ; Set pointer to proper scan line
  2108.     moveq    #0,d0
  2109.     move.w    x,d0
  2110.     mulu    #10,d0
  2111.     add.w    #251,d0        ; Now we're drawing on the Mask grid
  2112.     bra    di1_0
  2113.  
  2114. set_hotspot:
  2115.     dc.w    $A00A        ; Hide mouse
  2116.     move    x_hot,x        ; Get hotspot coordinates
  2117.     move    y_hot,y
  2118.     move.l    #hotpat,filptr
  2119.     bsr    d_int1        ; Draw it
  2120.     bsr    show_mouse    ; Show the mouse
  2121.     rts
  2122.  
  2123. get_iptr:
  2124.     moveq    #0,d0
  2125.     move    y,d0
  2126.     add.w    d0,d0
  2127.     add.l    #m_image,d0
  2128.     bra.s    btest
  2129.  
  2130. get_mptr:
  2131.     moveq    #0,d0
  2132.     move    y,d0
  2133.     add.w    d0,d0
  2134.     add.l    #m_mask,d0
  2135. *    bra.s    btest
  2136.  
  2137. btest:    move.l    d0,a0
  2138.     move    (a0),d1
  2139.     move    #15,d0
  2140.     sub.w    x,d0
  2141.     btst    d0,d1
  2142.     rts
  2143.  
  2144. init_col:
  2145.     move.b    #'0',dvalms
  2146.     move.b    #'0',mvalms
  2147.     move.b    #'0',dvalms+1
  2148.     move.b    #'0',mvalms+1
  2149.     move.l    #mvalms,a5
  2150.     moveq    #0,d0
  2151.     move    fg_col,d0
  2152.     bsr.s    setdec
  2153.     move.l    #dvalms,a5
  2154.     moveq    #0,d0
  2155.     move    bg_col,d0
  2156.     bsr.s    setdec
  2157.     rts
  2158.  
  2159. init_nfrm:
  2160.     move.b    #'0',fnvlms
  2161.     move.b    #'0',fnvlms+1
  2162.     move.b    #'0',spvlms
  2163.     move.b    #'0',spvlms+1
  2164.     move.l    #fnvlms,a5
  2165.     moveq    #0,d0
  2166.     move    nframs,d0
  2167.     bsr.s    setdec
  2168.     move.l    #spvlms,a5
  2169.     moveq    #0,d0
  2170.     move    delval,d0
  2171.     bsr.s    setdec
  2172.     rts
  2173.  
  2174. setdec:    addq.l    #1,a5
  2175. setd1:    subq.w    #1,d0
  2176.     bmi.s    setd2
  2177.     addq.b    #1,(a5)
  2178.     cmp.b    #':',(a5)
  2179.     bne    setd1
  2180.     move.b    #'0',(a5)
  2181.     addq.b    #1,-1(a5)
  2182.     bra    setd1
  2183. setd2:    rts
  2184.  
  2185. show_mouse:
  2186.     dc.w    $A000
  2187.     move.l    8(a0),a0
  2188.     move    #0,(a0)
  2189.     dc.w    $A009
  2190.     rts
  2191.  
  2192. open_file:
  2193.     clr.w    -(sp)
  2194.     move.l    a5,-(sp)
  2195.     move    #$3D,-(sp)
  2196.     trap    #1
  2197.     addq    #8,sp
  2198.     tst.w    d0
  2199.     rts
  2200.  
  2201. read_file:
  2202.     move.l    a5,-(sp)
  2203.     move.l    d5,-(sp)
  2204.     move    fhandl,-(sp)
  2205.     move    #$3F,-(sp)
  2206.     trap    #1
  2207.     add    #12,sp
  2208.     tst.l    d0
  2209.     rts
  2210.  
  2211. clos_file:
  2212.     move    fhandl,-(sp)
  2213.     move    #$3E,-(sp)
  2214.     trap    #1
  2215.     addq    #4,sp
  2216.     rts
  2217.  
  2218. delete_file:
  2219.     move.l    a0,-(sp)
  2220.     move.w    #$41,-(sp)
  2221.     trap    #1
  2222.     addq    #6,sp
  2223.     rts
  2224.  
  2225. chk_anfile:
  2226.     clr.w    a_good
  2227.     moveq    #0,d7
  2228.     move    #31,d6
  2229. chkan1:    move.l    d7,d0
  2230.     bsr    lseek
  2231.     bmi.s    chkan2
  2232.     move.l    #nfrtst,a5
  2233.     move.l    #4,d5
  2234.     bsr    read_file
  2235.     bmi.s    chkan2
  2236.     cmp.w    #15,(a5)
  2237.     bhi.s    chkan2
  2238.     cmp.w    #15,2(a5)
  2239.     bhi.s    chkan2
  2240.     addq.l    #6,d7
  2241.     move.l    d7,d0
  2242.     bsr    lseek
  2243.     bmi.s    chkan2
  2244.     bsr    read_file
  2245.     bmi.s    chkan2
  2246.     cmp.w    #15,(a5)
  2247.     bhi.s    chkan2
  2248.     cmp.w    #15,2(a5)
  2249.     bhi.s    chkan2
  2250.     add.l    #68,d7
  2251.     dbf    d6,chkan1
  2252.  
  2253.     move.l    #2368,d0
  2254.     bsr    lseek
  2255.     bmi.s    chkan2
  2256.     move.l    #nfrtst,a5
  2257.     move.l    #4,d5
  2258.     bsr    read_file
  2259.     bmi.s    chkan2
  2260.     cmp.w    #32,(a5)
  2261.     bhi.s    chkan2
  2262.     cmp.w    #99,2(a5)
  2263.     bhi.s    chkan2
  2264.     rts
  2265. chkan2:    move.w    #-1,a_good
  2266.     rts
  2267.  
  2268. write_mode:
  2269.     move.l    #contrl,a5
  2270.     move    #32,(a5)    ; Set writing mode
  2271.     move    #0,2(a5)
  2272.     move    #1,6(a5)
  2273.     bra    vdi
  2274.  
  2275. poly_color:
  2276.     move.l    #contrl,a5
  2277.     move    #17,(a5)    ; vsl_color (Set Polyline Color)
  2278.     move    #0,2(a5)
  2279.     move    #1,6(a5)
  2280.     bra    vdi
  2281.  
  2282. poly_type:
  2283.     move.l    #contrl,a5
  2284.     move    #15,(a5)    ; vsl_type (Set Polyline Type)
  2285.     move    #0,2(a5)
  2286.     move    #1,6(a5)
  2287.     bra    vdi
  2288.  
  2289. poly_width:
  2290.     move.l    #contrl,a5
  2291.     move    #16,(a5)    ; vsl_width (Set Polyline Width)
  2292.     move    #1,2(a5)
  2293.     move    #0,6(a5)
  2294.     bra    vdi
  2295.  
  2296. poly_ends:
  2297.     move.l    #contrl,a5
  2298.     move    #108,(a5)    ; vsl_ends (Set Polyline End Styles)
  2299.     move    #0,2(a5)
  2300.     move    #2,6(a5)
  2301.     bra    vdi
  2302.  
  2303. polyline:
  2304.     move.l    #contrl,a5
  2305.     move    #6,(a5)
  2306.     move    pt_num,2(a5)
  2307.     move    #0,6(a5)
  2308.     bra    vdi
  2309.  
  2310. vsf_color:
  2311.     move.l    #contrl,a5
  2312.     move    #25,(a5)
  2313.     move    #0,2(a5)
  2314.     move    #1,6(a5)
  2315.     bra    vdi
  2316.  
  2317. vsf_interior:
  2318.     move.l    #contrl,a5
  2319.     move    #23,(a5)
  2320.     move    #0,2(a5)
  2321.     move    #1,6(a5)
  2322.     bra    vdi
  2323.  
  2324. vsf_style:
  2325.     move.l    #contrl,a5
  2326.     move    #24,(a5)
  2327.     move    #0,2(a5)
  2328.     move    #1,6(a5)
  2329.     bra    vdi
  2330.  
  2331. exch_button:
  2332.     move.l    #contrl,a5    ; Point the mouse button routine
  2333.     move    #125,(a5)    ; to an RTS to prevent the AES from
  2334.     clr.w    2(a5)        ; buffering button presses
  2335.     clr.w    6(a5)
  2336.     move.l    #butrts,14(a5)
  2337.     bsr    vdi
  2338.     move.l    18(a5),badsav
  2339.     rts
  2340.  
  2341. repl_button:
  2342.     move.l    #contrl,a5
  2343.     move    #125,(a5)    ; Reset button vector so we can use the
  2344.     clr.w    2(a5)        ; AES again
  2345.     clr.w    6(a5)
  2346.     move.l    badsav,14(a5)
  2347.     bra    vdi
  2348.  
  2349. sample_mouse:
  2350.     move.l    #contrl,a5
  2351.     move    #124,(a5)
  2352.     move    #0,2(a5)
  2353.     move    #0,6(a5)
  2354.     bra    vdi
  2355.  
  2356. open_window:
  2357.     move.l    #w_get,aespb
  2358.     move.l    #intin,a5
  2359.     clr.w    (a5)
  2360.     move.w    #4,2(a5)
  2361.     bsr    aes
  2362.     move.l    intout+2,wx
  2363.     move.l    intout+6,ww
  2364.  
  2365.     move.l    #intin,a5
  2366.     move.l    #w_crea,aespb    ; Create a full-screen window
  2367.     clr.w    (a5)
  2368.     move.l    wx,2(a5)
  2369.     move.l    ww,6(a5)
  2370.     bsr    aes
  2371.     tst.w    intout        ; Error? (Probably too many windows open)
  2372.     bpl.s    openwi        ; No, continue
  2373.     move.w    #-1,d0
  2374.     rts
  2375. openwi:    move    intout,whandl
  2376.     move.l    #w_open,aespb    ; Open the window!
  2377.     move    whandl,(a5)    ; a5 is still pointing to intin
  2378.     move.l    wx,2(a5)
  2379.     move.l    ww,6(a5)
  2380.     bsr    aes
  2381.     moveq    #0,d0
  2382.     rts
  2383.  
  2384. fsel:    tst    fsflag
  2385.     bne.s    fsel1
  2386.  
  2387.     move.l    itmadr,a0    ; Change the "ITEM SELECTOR" text to something
  2388.     move.l    txtadr,(a0)    ; a bit more meaningful
  2389.     move    itmlen,8(a0)
  2390.     or.w    #1,-2(a0)
  2391.  
  2392. fsel1:    move.l    #f_sel,aespb    ; Let's call fsel_input with opcode 90
  2393.     move.l    diradr,addrin
  2394.     move.l    filadr,addrin+4
  2395.     bsr    aes
  2396.  
  2397.     tst    fsflag
  2398.     bne.s    fsel2
  2399.  
  2400.     move.l    itmadr,a0    ; Restore the fsel text line
  2401.     move.l    iasav,(a0)
  2402.     and.w    #$FE,-2(a0)
  2403.     move    ilensv,8(a0)
  2404.  
  2405. fsel2:    rts
  2406.  
  2407. set_path:
  2408.     clr.w    d0        ; Set current drive from output of
  2409.     move.l    diradr,a0    ; fsel routine
  2410.     move.b    (a0),d0
  2411.     sub.b    #65,d0
  2412.     move    d0,-(sp)
  2413.     move    #$0E,-(sp)
  2414.     trap    #1
  2415.     addq    #4,sp
  2416.     move.l    diradr,a0    ; Also set pathname from fsel
  2417.     addq.l    #2,a0
  2418.     move.l    #pathnm,a1
  2419.     move.l    #63,d5
  2420. pathlp:    tst.b    (a0)
  2421.     beq.s    plx1
  2422.     move.b    (a0)+,(a1)+
  2423.     dbf    d5,pathlp
  2424. plx1:    move.l    #63,d5
  2425. plp2:    cmp.b    #"\\",-(a1)
  2426.     beq.s    plx2
  2427.     dbf    d5,plp2
  2428. plx2:    clr.b    1(a1)
  2429.     pea    pathnm
  2430.     move    #$3B,-(sp)
  2431.     trap    #1
  2432.     addq    #6,sp
  2433.     rts
  2434.  
  2435. chk_extension:
  2436.     move.l    filadr,a0    ; Check to see if the chosen filename has
  2437. chke_1:    tst.b    (a0)        ; an extension. If not, add the proper one.
  2438.     beq.s    setext        ; If so, leave it alone
  2439.     cmp.b    #".",(a0)+
  2440.     beq.s    nosete
  2441.     bra    chke_1
  2442. setext:    move    #4,d0
  2443. setx1:    move.b    (a1)+,(a0)+
  2444.     dbf    d0,setx1
  2445. nosete:    rts
  2446.  
  2447. res_dpath:
  2448.     move    curdrv,-(sp)    ; Reset current drive and pathname
  2449.     move    #$0E,-(sp)
  2450.     trap    #1
  2451.     addq    #4,sp
  2452.     move.l    #curpth,-(sp)
  2453.     move    #$3B,-(sp)
  2454.     trap    #1
  2455.     addq    #6,sp
  2456.     rts
  2457.  
  2458. * form_alert
  2459. * Enter with a5= address of definition string
  2460. *         d5= number of default box
  2461.  
  2462. alert:    move.l    a5,addrin    ; Set address of string
  2463.     move    d5,intin    ; Set default box
  2464.     move.l    #f_alrt,aespb    ; Display alert box
  2465.     bra    aes
  2466.  
  2467. * Dialog box drawing routine
  2468.  
  2469. drawbx:    move.l    #f_cntr,aespb    ; First, let's call form_center
  2470.     bsr    aes
  2471.  
  2472.     move.l    #intout,a0
  2473.     move.l    2(a0),cx
  2474.     move.l    6(a0),cw
  2475.     subq.w    #2,cx
  2476.     subq.w    #2,cy
  2477.     addq.w    #6,cw
  2478.     addq.w    #6,ch
  2479.  
  2480.     tst    diflag
  2481.     bne.s    draw_1
  2482.  
  2483.     clr.w    intin
  2484.     bsr.s    dial
  2485.  
  2486. draw_1:    move.l    #intin,a5
  2487.     move.l    #o_cdrw,aespb    ; Objc_draw
  2488.     move    #0,(a5)        ; Root object gets drawn first
  2489.     move    #5,2(a5)    ; Up to 5 levels of subordinate objects
  2490.     move.l    cx,4(a5)    ; (dial subroutine sets a5->intin)
  2491.     move.l    cw,8(a5)
  2492.     bra    aes
  2493.  
  2494. dial:    move.l    #f_dial,aespb    ; Form_dial
  2495.     move.l    #intin,a5
  2496.     clr.l    2(a5)        ; No growing/shrinking boxes, so just
  2497.     clr.l    6(a5)        ; zero out the start coordinates
  2498.     move.l    cx,10(a5)
  2499.     move.l    cw,14(a5)
  2500.     bra    aes
  2501.  
  2502. obdraw:    move.l    #o_cdrw,aespb
  2503.     move.l    #intin,a0
  2504.     move    o_indx,(a0)
  2505.     move    #1,2(a0)
  2506.     move.l    x_obj1,4(a0)
  2507.     move.l    w_obj,8(a0)
  2508.     move.l    #editbx,addrin
  2509.     bra.s    aes
  2510.  
  2511. formdo:    move.l    #f_do,aespb    ; Call form_do to get user input
  2512.     clr.w    intin        ; No editable text field
  2513.     bra.s    aes        ; Do it!
  2514.  
  2515. objoff:    move.l    #o_coff,aespb    ; Calculate clipping rectangle and re-draw
  2516.     bsr.s    aes        ; an object. intin must be set to the index
  2517.     move.l    #o_cdrw,aespb    ; of the object to be drawn, addrin to the
  2518.     move.l    #intin+2,a5    ; address of the parent object tree
  2519.     move    #0,(a5)+
  2520.     move    intout+2,(a5)
  2521.     addq.w    #1,(a5)+
  2522.     move    intout+4,(a5)
  2523.     addq.w    #1,(a5)+
  2524.     moveq    #0,d0
  2525.     move    intin,d0
  2526.     mulu    #24,d0
  2527.     add.l    addrin,d0
  2528.     move.l    d0,a0
  2529.     move    20(a0),(a5)
  2530.     subq.w    #2,(a5)+
  2531.     move    22(a0),(a5)
  2532.     subq.w    #2,(a5)+
  2533.     bra.s    aes
  2534.  
  2535. * VDI and AES subroutines
  2536.  
  2537. vdi:    move    vhandl,12(a5)
  2538. vdi1:    move.l    #vdipb,d1
  2539.     move.l    #$73,d0
  2540.     trap    #2
  2541. butrts:    rts
  2542.  
  2543. aes:    move.l    #aespb,d1
  2544.     move.l    #$C8,d0
  2545.     trap    #2
  2546.     rts
  2547.  
  2548.  
  2549. my_vblank:
  2550.     movem.l    d0/a0-a3,-(sp)    ; Save registers
  2551.     cmp.b    #2,sshiftmod    ; High res?
  2552.     beq.s    vbl1        ; Yes, skip the res check
  2553.     tst    lowflg        ; Did we find the Set Preferences dialog?
  2554.     bne.s    vbl1
  2555.     move.l    res_optr,a0
  2556.     btst    #0,1(a0)    ; SELECTED? (Changing resolution?)
  2557.     beq.s    vbl1        ; No, continue
  2558.     move.l    res_okptr,a0    ; Now check the "OK" button
  2559.     btst    #0,1(a0)    ; SELECTED? (_really_ changing?)
  2560.     beq.s    vbl1        ; Not yet!
  2561.     move.l    line_a,a0
  2562.     btst    #0,but_stat(a0)    ; Let go of the left button yet???
  2563.     bne.s    vbl1        ; The suspense is killing me!
  2564.  
  2565.     move.l    sysvc1,$70    ; Remove the vertical blank interrupt
  2566.     clr    insflg        ; Clear installed flag
  2567.     move.l    $502,a0
  2568.     cmp.l    #$ABADBABE,2(a0)
  2569.     bne    fall_thru
  2570.     move.l    22(a0),$B4    ; The infamous kludge for ALT.ACC
  2571.     bra    fall_thru    ; And bail
  2572.  
  2573. vbl1:    tst    vbi_on        ; Are we interrupting?
  2574.     beq    fall_thru    ; Nope!
  2575.     move.l    line_a,a0
  2576.     tst.b    ignore(a0)    ; Ignore the mouse?
  2577.     bne.s    fall_thru    ; Do so
  2578.  
  2579. ckarrw:    move.l    sprtad,a0    ; The address of the mouse sprite definition
  2580.     move.l    a0,a2
  2581.     move.l    #arrow_data,a1
  2582.     move    #15,d0        ; 16 longwords
  2583. vbl2:    cmp.l    (a0)+,(a1)+    ; Did somebody put an arrow in here???
  2584.     bne.s    vbl4        ; No, I guess not
  2585.     dbf    d0,vbl2
  2586.  
  2587.     tst    onoff
  2588.     bne.s    vbl2a
  2589.     move.l    #m_form2,a3
  2590.     bra.s    vbl2b
  2591. vbl2a:    bsr    which_mouse
  2592. vbl2b:    bsr.s    stuff_it
  2593.     bsr    force_it    ; Force the OS to show the mouse
  2594.  
  2595. vbl4:
  2596.     tst    onoff        ; Animation on?
  2597.     beq.s    fall_thru    ; Nope, bail
  2598.     subq.w    #1,vbtimr    ; Decrement animation timer
  2599.     bpl.s    fall_thru    ; Not time yet, bail
  2600.     move.w    delval,vbtimr    ; Reset timer
  2601.     move.w    nframs,d0    ; Get number of frames in the loop
  2602.     subq.w    #1,d0
  2603.     cmp.w    moucnt,d0    ; Are we at the last frame?
  2604.     bhi.s    vbl5        ; No, skip ahead
  2605.     clr.w    moucnt        ; Clear the frame counter
  2606.     bra.s    vbl6
  2607. vbl5:    addq.w    #1,moucnt    ; Increment frame counter
  2608. vbl6:    bsr.s    which_mouse    ; Get pointer to mouse data
  2609.     move.l    sprtad,a2
  2610.     bsr.s    stuff_it
  2611.     bsr.s    force_it
  2612.  
  2613. fall_thru:
  2614.     movem.l    (sp)+,d0/a0-a3    ; Restore them registers, pal
  2615. sysj1:    jmp    $DEADBEEF    ; Jump to system VBI routine
  2616. sysvc1    =    sysj1+2
  2617.  
  2618. stuff_it:
  2619.     move.l    (a3),-10(a2)    ; Caught you red-handed! Set the hot spot
  2620.     moveq    #0,d0
  2621.     move    6(a3),d0    ; Get mask color
  2622.     bsr.s    vb_color    ; Go adjust the color
  2623.     move    d0,-4(a2)    ; Set the color
  2624.     move    8(a3),d0    ; Get data color
  2625.     bsr.s    vb_color    ; Adjust it
  2626.     move    d0,-2(a2)    ; Set it
  2627.     move.l    a3,a0
  2628.     add.l    #10,a0        ; The data is stored in sprite format
  2629.     move.l    a3,a1
  2630.     add.l    #42,a1        ; --- alternating words of data and mask
  2631.     move    #15,d0
  2632. stuff2:    move    (a0)+,(a2)+    ; Take that!
  2633.     move    (a1)+,(a2)+    ; The mouse thief strikes!
  2634.     dbf    d0,stuff2
  2635.     rts
  2636.  
  2637. which_mouse:
  2638.     moveq    #0,d0
  2639.     move.w    moucnt,d0
  2640.     mulu    #74,d0
  2641.     add.l    #mouse_array,d0
  2642.     move.l    d0,a3
  2643.     rts
  2644.  
  2645. vb_color:
  2646.     move.l    valsav,a0
  2647.     add.l    d0,a0        ; Add color value to start of table
  2648.     move.b    (a0),d0        ; Get adjusted color
  2649.     rts
  2650.  
  2651. force_it:
  2652.     bsr.s    pac_butt
  2653.     tst    mouse_x(a0)    ; Are we at the left edge of the screen?
  2654.     bne.s    force1        ; No, skip over
  2655.     addq    #1,mouse_x(a0)    ; Move it right
  2656.     move.b    #$FF,anipac+1    ; Move it back left
  2657.     bra.s    pac_send
  2658. force1:    subq    #1,mouse_x(a0)    ; Move it left
  2659.     move.b    #$01,anipac+1    ; Move it back right
  2660. force2:    bra.s    pac_send
  2661.  
  2662. pac_butt:
  2663.     move.b    #$F8,anipac
  2664.     move.l    line_a,a0
  2665.     btst.b    #0,but_stat(a0)
  2666.     beq.s    pacb2
  2667.     bset.b    #1,anipac
  2668. pacb2:    btst.b    #1,but_stat(a0)
  2669.     beq.s    pacb3
  2670.     bset.b    #0,anipac
  2671. pacb3:    rts
  2672.  
  2673. pac_send:
  2674.     move.l    #anipac,a0
  2675.     move.w    sr,srsave
  2676.     or.w    #$700,sr
  2677. j_add2:    jsr    $DEADBEEF
  2678. sysvc2    =    j_add2+2
  2679.     move.w    srsave,sr
  2680.     rts
  2681.  
  2682.  
  2683. save_vbv:
  2684.     move.l    ipl_vec,sysvc1
  2685.     move.l    #my_vblank,ipl_vec
  2686.  
  2687.     move.l    $502,a0
  2688.     cmp.l    #$ABADBABE,2(a0)
  2689.     bne.s    getmsv
  2690.     move.l    18(a0),a0
  2691.     bra.s    getms1
  2692. getmsv:    move.w    #34,-(sp)    ; Xbios kbdvbase
  2693.     trap    #14
  2694.     addq    #2,sp
  2695.     move.l    d0,a0
  2696.     move.l    16(a0),a0    ; Save mouse interrupt vector
  2697. getms1:    move.l    a0,sysvc2
  2698.     rts
  2699.  
  2700.  
  2701.     .data
  2702.     .even
  2703.  
  2704. vdipb:    dc.l    contrl,intin,ptsin,intout,ptsout
  2705. aespb:    dc.l    contrl,global,intin,intout,addrin,addrout
  2706.  
  2707. a_init:    dc.w    10,0,1,0,0
  2708. e_mesg:    dc.w    23,0,1,1,0
  2709. e_timr:    dc.w    24,2,1,0,0
  2710. m_reg:    dc.w    35,1,1,1,0
  2711. g_hand:    dc.w    77,0,5,0,0
  2712. g_mous:    dc.w    78,1,1,1,0
  2713. r_obfx:    dc.w    114,1,1,1,0
  2714. f_dial:    dc.w    51,9,1,1,0
  2715. f_alrt:    dc.w    52,1,1,1,0
  2716. f_cntr:    dc.w    54,0,5,1,0
  2717. f_do:    dc.w    50,1,2,1,0
  2718. o_cdrw:    dc.w    42,6,1,1,0
  2719. o_cfnd:    dc.w    43,4,1,1,0
  2720. o_coff:    dc.w    44,1,3,1,0
  2721. f_sel:    dc.w    90,0,2,2,0
  2722. w_crea:    dc.w    100,5,1,0,0
  2723. w_open:    dc.w    101,5,5,0,0
  2724. w_clos:    dc.w    102,1,1,0,0
  2725. w_del:    dc.w    103,1,1,0,0
  2726. w_get:    dc.w    104,2,5,0,0
  2727. w_updt:    dc.w    107,1,1,0,0
  2728.  
  2729. ob_inx:    dc.w    savebt,loadbt,clrmbt,clrdbt,invdbt,invmbt
  2730.     dc.w    upbt,leftbt,downbt,ritebt,mirdbt,mirmbt,rotbt
  2731.     dc.w    exitbt,instbt,remvbt,undobt,cdowbt,cupbt,colttl
  2732.     dc.w    frmttl,frdown,frup,anonof
  2733. o_dum:    dc.w    0
  2734. oi_len    =    (o_dum-ob_inx)/2
  2735.  
  2736. rtn_table:
  2737.     dc.l    save,load,clr_mask,clr_data,inv_data,inv_mask
  2738.     dc.l    up,left,down,right,mir_data,mir_mask,rotate
  2739.     dc.l    exit,install,remove,undo,colr_down,colr_up,sw_fgbg
  2740.     dc.l    sw_anttl,ani_down,ani_up,ani_onoff
  2741.  
  2742. low_val:
  2743.     dc.b    0,15,1,2,4,6,3,5,7,8,9,10,12,14,11,13
  2744. med_val:
  2745.     dc.b    0,15,1,2,15,15,15,15,15,15,15,15,15,15,15,15
  2746. hi_val:
  2747.     dc.b    0,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
  2748.  
  2749. y_off:    dc.w    100
  2750. y_bot:    dc.w    260
  2751.  
  2752. chang1:    dc.w    180
  2753. chang2:    dc.w    140
  2754.  
  2755. y_div:    dc.w    10
  2756.  
  2757. y_scr:    dc.w    80
  2758.  
  2759. celsiz:    dc.w    9
  2760.  
  2761. fillst:    dc.w    2
  2762.  
  2763. filhot:    dc.w    5
  2764.  
  2765. empty:    dc.w    $0000,$0000
  2766. mempty:    dc.w    $0000,$0000
  2767.  
  2768. dots:    dc.w    $AA80,$0000
  2769. mdots:    dc.w    $0000,$FF80
  2770.  
  2771. black:    dc.w    $FF80,$FF80
  2772. mblack:    dc.w    $FF80,$FF80
  2773.  
  2774. hotpat:    dc.w    $5500,$FF80
  2775. mhotpt:    dc.w    $FF80,$0000
  2776.  
  2777. mouse_form:
  2778. x_hot:    dc.w    0
  2779. y_hot:    dc.w    0
  2780. planes:    dc.w    1
  2781. fg_col:    dc.w    0
  2782. bg_col:    dc.w    1
  2783. m_mask:
  2784.     dc.w    $C000,$E000,$F000,$F800
  2785.     dc.w    $FC00,$FE00,$FF00,$FF80
  2786.     dc.w    $FFC0,$FFE0,$FE00,$EF00
  2787.     dc.w    $CF00,$8780,$0780,$0380
  2788. m_image:
  2789.     dc.w    $0000,$4000,$6000,$7000
  2790.     dc.w    $7800,$7C00,$7E00,$7F00
  2791.     dc.w    $7F80,$7C00,$6C00,$4600
  2792.     dc.w    $0600,$0300,$0300,$0000
  2793.  
  2794. arrow_data:
  2795.     dc.w    $C000,$0000,$E000,$4000    ; Data for arrow cursor in sprite
  2796.     dc.w    $F000,$6000,$F800,$7000    ; format (alternating words of mask
  2797.     dc.w    $FC00,$7800,$FE00,$7C00    ; and data)
  2798.     dc.w    $FF00,$7E00,$FF80,$7F00
  2799.  
  2800.     dc.w    $FFC0,$7F80,$FFE0,$7C00
  2801.     dc.w    $FE00,$6C00,$EF00,$4600
  2802.     dc.w    $CF00,$0600,$8780,$0300
  2803.     dc.w    $0780,$0300,$0380,$0000
  2804.  
  2805. * TEDINFO structures
  2806.  
  2807. tinf0:    dc.l    stlog,dummy,dummy    ; ST-Log Presents
  2808.     dc.w    5,6,1,$1000,0,-1,17,1
  2809. tinf1:    dc.l    copyrt,dummy,dummy    ; Copyright 1987
  2810.     dc.w    5,6,2,$1000,0,-1,15,1
  2811. tinf2:    dc.l    footbl,dummy,dummy    ; Little Green Footballs
  2812.     dc.w    5,6,2,$1000,0,-1,23,1
  2813. tinf3:    dc.l    dcolms,dummy,dummy    ; Data/Mask color message
  2814.     dc.w    5,6,2,$1180,0,-1,11,1
  2815. tinf4:    dc.l    framms,dummy,dummy    ; Frame/#/Speed message
  2816.     dc.w    5,6,2,$1180,0,-1,6,1
  2817. tinf5:    dc.l    anofms,dummy,dummy    ; Animation ON/OFF message
  2818.     dc.w    5,6,2,$1180,0,-1,14,1
  2819.  
  2820. tinf10:    dc.l    dcolms,dummy,dummy    ; Low res Data/Mask message
  2821.     dc.w    5,6,2,$1180,0,-1,11,1
  2822.  
  2823. * Editor dialog box
  2824.  
  2825. editbx:    dc.w    -1,1,32,G_BOX,NONE,SHADOWED
  2826.     dc.l    $FF1100
  2827.     dc.w    0,0,76,20
  2828.  
  2829.     dc.w    5,2,4,G_STRING,NONE,SELECTED
  2830.     dc.l    mousms
  2831.     dc.w    0,0,76,2
  2832.  
  2833.     dc.w    3,-1,-1,G_TEXT,NONE,NORMAL
  2834.     dc.l    tinf0
  2835.     dc.w    1,0,13,2
  2836.  
  2837.     dc.w    4,-1,-1,G_TEXT,NONE,NORMAL
  2838.     dc.l    tinf1
  2839. cop_co:    dc.w    57,0,17,1
  2840.  
  2841.     dc.w    1,-1,-1,G_TEXT,NONE,NORMAL
  2842.     dc.l    tinf2
  2843. footco:    dc.w    57,1,17,1
  2844.  
  2845.     dc.w    6,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2846.     dc.l    instms
  2847.     dc.w    66,3,8,1
  2848.  
  2849.     dc.w    7,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2850.     dc.l    remvms
  2851.     dc.w    66,5,8,1
  2852.  
  2853.     dc.w    8,-1,-1,G_BOXTEXT,NONE,NORMAL
  2854.     dc.l    tinf3
  2855.     dc.w    65,7,10,1
  2856.  
  2857.     dc.w    9,-1,-1,G_BOXCHAR,NONE,NORMAL
  2858.     dc.l    $2FF1100
  2859.     dc.w    65,8,3,2
  2860.  
  2861.     dc.w    10,-1,-1,G_BUTTON,SELECTABLE,NORMAL
  2862. valadr:    dc.l    dvalms
  2863. col_co:    dc.w    68,8,4,2
  2864.  
  2865.     dc.w    11,-1,-1,G_BOXCHAR,NONE,NORMAL
  2866.     dc.l    $1FF1100
  2867.     dc.w    72,8,3,2
  2868.  
  2869.     dc.w    12,-1,-1,G_BOXCHAR,NONE,SHADOWED
  2870.     dc.l    $1FF1100
  2871. upco:    dc.w    57,9,2,1
  2872.  
  2873.     dc.w    13,-1,-1,G_BOXCHAR,NONE,SHADOWED
  2874.     dc.l    $4FF1100
  2875. leftco:    dc.w    53,11,2,1
  2876.  
  2877.     dc.w    14,-1,-1,G_BOXCHAR,NONE,SHADOWED
  2878.     dc.l    $3FF1100
  2879. riteco:    dc.w    61,11,2,1
  2880.  
  2881.     dc.w    15,-1,-1,G_BOXTEXT,NONE,NORMAL
  2882.     dc.l    tinf4
  2883.     dc.w    65,11,10,1
  2884.  
  2885.     dc.w    16,-1,-1,G_BOXCHAR,NONE,NORMAL
  2886.     dc.l    $2FF1100
  2887.     dc.w    65,12,3,2
  2888.  
  2889.     dc.w    17,-1,-1,G_BUTTON,SELECTABLE,NORMAL
  2890. anival:    dc.l    frvlms
  2891.     dc.w    68,12,4,2
  2892.  
  2893.     dc.w    18,-1,-1,G_BOXCHAR,NONE,NORMAL
  2894.     dc.l    $1FF1100
  2895.     dc.w    72,12,3,2
  2896.  
  2897.     dc.w    19,-1,-1,G_BOXCHAR,NONE,SHADOWED
  2898.     dc.l    $2FF1100
  2899. downco:    dc.w    57,13,2,1
  2900.  
  2901.     dc.w    20,-1,-1,G_STRING,NONE,SELECTED
  2902.     dc.l    dat_ms
  2903. datco:    dc.w    11,14,6,1
  2904.  
  2905.     dc.w    21,-1,-1,G_STRING,NONE,SELECTED
  2906.     dc.l    maskms
  2907. mskco:    dc.w    36,14,6,1
  2908.  
  2909.     dc.w    22,-1,-1,G_BOXTEXT,NONE
  2910. anistt:    dc.w    NORMAL
  2911.     dc.l    tinf5
  2912.     dc.w    65,14,10,1
  2913.  
  2914.     dc.w    23,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2915.     dc.l    savems
  2916.     dc.w    2,16,7,1
  2917.  
  2918.     dc.w    24,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2919.     dc.l    clrdms
  2920.     dc.w    11,16,12,1
  2921.  
  2922.     dc.w    25,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2923.     dc.l    invdms
  2924.     dc.w    24,16,12,1
  2925.  
  2926.     dc.w    26,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2927.     dc.l    mirdms
  2928.     dc.w    37,16,12,1
  2929.  
  2930.     dc.w    27,-1,-1,G_BUTTON,SELECTABLE
  2931. extstt:    dc.w    SHADOWED
  2932.     dc.l    exitms
  2933.     dc.w    67,16,7,3
  2934.  
  2935.     dc.w    28,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2936.     dc.l    undoms
  2937.     dc.w    58,16,7,3
  2938.  
  2939.     dc.w    29,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2940.     dc.l    rotms
  2941.     dc.w    50,16,7,3
  2942.  
  2943.     dc.w    30,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2944.     dc.l    loadms
  2945.     dc.w    2,18,7,1
  2946.  
  2947.     dc.w    31,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2948.     dc.l    clrmms
  2949.     dc.w    11,18,12,1
  2950.  
  2951.     dc.w    32,-1,-1,G_BUTTON,SELECTABLE,SHADOWED
  2952.     dc.l    invmms
  2953.     dc.w    24,18,12,1
  2954.  
  2955.     dc.w    0,-1,-1,G_BUTTON,$21,SHADOWED
  2956.     dc.l    mirmms
  2957.     dc.w    37,18,12,1
  2958.  
  2959. ed_adr:    dc.l    editbx
  2960.  
  2961. objnum    =    (ed_adr-editbx)/24-1
  2962.  
  2963. * Low-res dialog box
  2964.  
  2965. lowbox:    dc.w    -1,1,14,G_BOX,NONE,SHADOWED
  2966.     dc.l    $FF1100
  2967.     dc.w    0,0,38,14
  2968.  
  2969.     dc.w    2,-1,-1,G_STRING,NONE,SELECTED
  2970.     dc.l    lttlms
  2971.     dc.w    0,0,38,2
  2972.  
  2973.     dc.w    3,-1,-1,G_STRING,NONE,NORMAL
  2974.     dc.l    lms1
  2975.     dc.w    1,3,23,1
  2976.  
  2977.     dc.w    4,-1,-1,G_BUTTON,$5
  2978. loistt:    dc.w    NORMAL
  2979.     dc.l    loadms
  2980.     dc.w    26,3,10,1
  2981.  
  2982.     dc.w    5,-1,-1,G_STRING,NONE,NORMAL
  2983.     dc.l    lms2
  2984.     dc.w    1,4,18,1
  2985.  
  2986.     dc.w    6,-1,-1,G_BUTTON,$5
  2987. losstt:    dc.w    NORMAL
  2988.     dc.l    savems
  2989.     dc.w    26,5,10,1
  2990.  
  2991.     dc.w    7,-1,-1,G_STRING,NONE,NORMAL
  2992.     dc.l    lms3
  2993.     dc.w    1,6,22,1
  2994.  
  2995.     dc.w    8,-1,-1,G_BUTTON,$5
  2996. lorstt:    dc.w    NORMAL
  2997.     dc.l    remvms
  2998.     dc.w    26,7,10,1
  2999.  
  3000.     dc.w    9,-1,-1,G_STRING,NONE,NORMAL
  3001.     dc.l    lms4
  3002.     dc.w    1,7,19,1
  3003.  
  3004.     dc.w    10,-1,-1,G_STRING,NONE,NORMAL
  3005.     dc.l    lms5
  3006.     dc.w    1,8,20,1
  3007.  
  3008.     dc.w    11,-1,-1,G_BOXTEXT,TOUCHEXIT
  3009. locstt:    dc.w    NORMAL
  3010.     dc.l    tinf10
  3011.     dc.w    7,10,10,1
  3012.  
  3013.     dc.w    12,-1,-1,G_BUTTON,$7
  3014. loestt:    dc.w    NORMAL
  3015.     dc.l    exitms
  3016.     dc.w    26,10,10,2
  3017.  
  3018.     dc.w    13,-1,-1,G_BOXCHAR,TOUCHEXIT
  3019. lodstt:    dc.w    NORMAL
  3020.     dc.l    $2FF1100
  3021.     dc.w    7,11,3,2
  3022.  
  3023.     dc.w    14,-1,-1,G_BUTTON,NONE,NORMAL
  3024. lovadr:    dc.l    dvalms
  3025.     dc.w    10,11,4,2
  3026.  
  3027.     dc.w    0,-1,-1,G_BOXCHAR,$60
  3028. loustt:    dc.w    NORMAL
  3029.     dc.l    $1FF1100
  3030.     dc.w    14,11,3,2
  3031.  
  3032. lo_adr:    dc.l    lowbox
  3033.  
  3034. lo_num    =    (lo_adr-lowbox)/24-1
  3035.  
  3036.  
  3037. * Text for dialog objects
  3038.  
  3039. stlog:    dc.b    'ST-Log Presents:',0
  3040. copyrt:    dc.b    'Copyright 1987',0
  3041. footbl:    dc.b    'Little Green Footballs'
  3042. dummy:    dc.b    0
  3043.  
  3044. mousms:    dc.b    '                 MOUSE-KA-MANIA! by Charles F. Johnson',0
  3045. instms:    dc.b    'Install',0
  3046. remvms:    dc.b    'Remove',0
  3047. savems:    dc.b    'Save',0
  3048. loadms:    dc.b    'Load',0
  3049. clrdms:    dc.b    'Clear Data',0
  3050. clrmms:    dc.b    'Clear Mask',0
  3051. invdms:    dc.b    'Invert Data',0
  3052. invmms:    dc.b    'Invert Mask',0
  3053. mirdms:    dc.b    'Mirror Data',0
  3054. mirmms:    dc.b    'Mirror Mask',0
  3055. rotms:    dc.b    'Rotate',0
  3056. exitms:    dc.b    'EXIT',0
  3057. undoms:    dc.b    'UNDO',0
  3058. dat_ms:    dc.b    ' DATA',0
  3059. maskms:    dc.b    ' MASK',0
  3060. dvalms:    dc.b    '01',0
  3061. mvalms:    dc.b    '00',0
  3062. frvlms:    dc.b    '01',0
  3063. fnvlms:    dc.b    '01',0
  3064. spvlms:    dc.b    '00',0
  3065. blnkms:    dc.b    '  ',0
  3066.  
  3067. dcolms:    dc.b    'Data Color',0
  3068. mcolms:    dc.b    'Mask Color',0
  3069. framms:    dc.b    'Current Frame',0
  3070. frmnms:    dc.b    '# of Frames',0
  3071. speems:    dc.b    'Delay',0
  3072. anonms:    dc.b    'Animation ON',0
  3073. anofms:    dc.b    'Animation OFF',0
  3074.  
  3075. lttlms:    dc.b    " Mouse-Ka-Mania by Charles F. Johnson ",0
  3076. lms1:    dc.b    "The Editor doesn't work",0
  3077. lms2:    dc.b    "in low resolution.",0
  3078. lms3:    dc.b    "However, you may still",0
  3079. lms4:    dc.b    "install or remove a",0
  3080. lms5:    dc.b    "custom mouse cursor!",0
  3081.  
  3082.     .even
  3083.  
  3084. itmtxt:    dc.b    'ITEM SELECTOR'
  3085.  
  3086. restxt:    dc.b    'Low',0,'Medium',0,'High'
  3087.  
  3088. datext:    dc.b    ':\\*.DAT',0
  3089. aniext:    dc.b    ':\\*.MKM',0
  3090.  
  3091. i_save:    dc.b    ' Save Mouse Data to which File? '
  3092. is_dum:    dc.b    0
  3093. is_len    =    (is_dum-i_save)*8
  3094.  
  3095. i_asav:    dc.b    ' Save Animation to which File? '
  3096. ia_dum:    dc.b    0
  3097. iaslen    =    (ia_dum-i_asav)*8
  3098.  
  3099. i_load:    dc.b    ' Load Mouse Data from which File? '
  3100. il_dum:    dc.b    0
  3101. il_len    =    (il_dum-i_load)*8
  3102.  
  3103. i_aloa:    dc.b    ' Load Animation from which File? '
  3104. ial_du:    dc.b    0
  3105. iallen    =    (ial_du-i_aloa)*8
  3106.  
  3107. dat_or_ani:
  3108.     dc.b    '[2][   Which type of file?       | ]'
  3109.     dc.b    '[Animation|Single Frame]'
  3110.  
  3111. notani:
  3112.     dc.b    '[3][ This is not a Mouse-Ka-Mania |'
  3113.     dc.b    ' animation file. | ]'
  3114.     dc.b    '[ Oops! ]'
  3115.  
  3116. exist:
  3117.     dc.b    '[3][ The file '
  3118. exname:    dc.b    '             | already exists! | |'
  3119.     dc.b    ' Over-write it?| ]'
  3120.     dc.b    '[ Yes | No ]'
  3121.  
  3122. dskful:    dc.b    '[3][ This disk is full! | ][ Oops! ]'
  3123.  
  3124. accmsg:    dc.b    '  Mouse-ka-Mania!',0
  3125.  
  3126. lowdef:    dc.b    '\\MOUSELOW.DEF',0
  3127. meddef:    dc.b    '\\MOUSEMED.DEF',0
  3128. hidef:    dc.b    '\\MOUSEHI.DEF',0
  3129.  
  3130. anipac:    dc.b    0,0,0,0
  3131.  
  3132.     .bss
  3133.     .even
  3134.  
  3135. line_a:    ds.l    1
  3136. valsav:    ds.l    1
  3137. temp:    ds.l    1
  3138. o_asav:    ds.l    1
  3139. itmadr:    ds.l    1
  3140. iasav:    ds.l    1
  3141. txtadr:    ds.l    1
  3142. diradr:    ds.l    1
  3143. filadr:    ds.l    1
  3144. badsav:    ds.l    1
  3145. sprtad:    ds.l    1
  3146. screen:    ds.l    1
  3147. filptr:    ds.l    1
  3148. nfrtst:    ds.l    1
  3149. res_optr:
  3150.     ds.l    1
  3151. res_okptr:
  3152.     ds.l    1
  3153.  
  3154. scncnt:    ds.w    1
  3155. srsave:    ds.w    1
  3156. fsflag:    ds.w    1
  3157. lowflg:    ds.w    1
  3158. o_res:    ds.w    1
  3159. res:    ds.w    1
  3160. menuid:    ds.w    1
  3161. curdrv:    ds.w    1
  3162. colflg:    ds.w    1
  3163. adflag:    ds.w    1
  3164. antflg:    ds.w    1
  3165. shfflg:    ds.w    1
  3166. onoff:    ds.w    1
  3167. vbi_on:    ds.w    1
  3168. vbtimr:    ds.w    1
  3169. moucnt:    ds.w    1
  3170. franum:    ds.w    1
  3171. nframs:    ds.w    1
  3172. delval:    ds.w    1
  3173.  
  3174. diflag:    ds.w    1
  3175. insflg:    ds.w    1
  3176. itmlen:    ds.w    1
  3177. ilensv:    ds.w    1
  3178. numrtn:    ds.w    1
  3179. butflg:    ds.w    1
  3180. o_indx:    ds.w    1
  3181. hotflg:    ds.w    1
  3182. m_flag:    ds.w    1
  3183. d_flag:    ds.w    1
  3184. a_good:    ds.w    1
  3185. pt_num:    ds.w    1
  3186. ghandl:    ds.w    1
  3187. vhandl:    ds.w    1
  3188. whandl:    ds.w    1
  3189. fhandl:    ds.w    1
  3190. butsav:    ds.w    1
  3191. mousex:    ds.w    1
  3192. mousey:    ds.w    1
  3193. x:    ds.w    1
  3194. y:    ds.w    1
  3195. cx:    ds.w    1
  3196. cy:    ds.w    1
  3197. cw:    ds.w    1
  3198. ch:    ds.w    1
  3199. wx:    ds.w    1
  3200. wy:    ds.w    1
  3201. ww:    ds.w    1
  3202. wh:    ds.w    1
  3203. x_obj1:    ds.w    1
  3204. y_obj1:    ds.w    1
  3205. x_obj2:    ds.w    1
  3206. y_obj2:    ds.w    1
  3207. w_obj:    ds.w    1
  3208. h_obj:    ds.w    1
  3209.  
  3210. l_type:    ds.w    1
  3211. l_colr:    ds.w    1
  3212. d_mode:    ds.w    1
  3213. l_strt:    ds.w    1
  3214. l_end:    ds.w    1
  3215. l_wid:    ds.w    1
  3216. f_type:    ds.w    1
  3217. f_colr:    ds.w    1
  3218. f_patt:    ds.w    1
  3219.  
  3220. * GEM arrays
  3221.  
  3222. contrl:    ds.w    12
  3223. intin:    ds.w    128
  3224. ptsin:    ds.w    128
  3225. intout:    ds.w    128
  3226. ptsout:    ds.w    128
  3227. global:
  3228. apvrsn:    ds.w    1
  3229. apcont:    ds.w    1
  3230. apid:    ds.w    1
  3231. apprvt:    ds.l    1
  3232. apptre:    ds.l    1
  3233. ap1rsv:    ds.l    1
  3234. ap2rsv:    ds.l    1
  3235. ap3rsv:    ds.l    1
  3236. ap4rsv:    ds.l    1
  3237.  
  3238. addrin:    ds.w    128
  3239. addrout:ds.w    128
  3240.  
  3241. m_form2:
  3242.     ds.b    74        ; The installed mouse form
  3243.  
  3244. hotsav:
  3245.     ds.l    1        ; Hot spot undo
  3246.  
  3247. mouse_save:
  3248.     ds.w    32        ; Undo buffer
  3249.  
  3250. m_rotate:
  3251.     ds.w    32        ; Rotation buffer
  3252.  
  3253. mouse_array:
  3254.     ds.b    74*32        ; Animation array
  3255.  
  3256. savfil:    ds.b    16
  3257. svafil:    ds.b    16
  3258. lodfil:    ds.b    16
  3259. loafil:    ds.b    16
  3260.  
  3261. savdir:    ds.b    64
  3262. svadir:    ds.b    64
  3263. loddir:    ds.b    64
  3264. loadir:    ds.b    64
  3265.  
  3266. pathnm:    ds.b    64
  3267. curpth:    ds.b    64
  3268.  
  3269. mspipe:    ds.b    32
  3270.  
  3271. dta:    ds.b    44
  3272.  
  3273.     ds.l    300        ; Reserve 1200 bytes for stack
  3274. ustack:    ds.l    1
  3275.     ds.w    10
  3276.